Professional Documents
Culture Documents
02
Total Marks: 20
Semester: Fall 2022
Compiler Construction CS506 Due Date: 25th Jan, 2023
Instructions:
Please read the following instructions carefully before submitting assignment. It should be clear that
your assignment will not get any credit if:
Objectives:
The objective of this assignment is to provide hands-on experience of Java Programming concepts
including:
Servlet Basics
Process Request
Member Functions and main function
Note: No need to write complete code, just write the code in processRequest() method of each Servlet,
as shown below.
Solution Sample:
Solution:
protected void processRequest(HttpServletRequest request,
response HttpServletResponse)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
// get the salary text value from the HTML form
String bamot = request.getParameter("bamot");
// convert to integer.
int sal = Integer.parseInt(bamot);
// calculation of 15% tax
int tax = (int)(sal * 0.10);
// convert tax to string
String taxValue = tax + "";
The file was created by Vu Expert | Subscribe YouTube Channel: Vu Expert |
Solution:-
protected void processRequest(HttpServletRequest request,
response HttpServletResponse)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String biamot = request.getParameter("bamot");
String tax = (String)request.getAttribute("tax");
// generate HTML tags using PrintWriter
out.println("<html>");
The file was created by Vu Expert | Subscribe YouTube Channel: Vu Expert |
out.println("<head>");
out.println("<title>SecondServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h3> Salary " + biamot+ "</h3>");
out.println("<h3> Tax " + tax+ "</h3>");
out.println("</body>");
out.println("</html>");
out.close();
}
}
BEST OF LUCK