CS506 Assignment No 3
Dear students, here you can read and download CS506 Assignment No 3 Solution Spring 2017. Assignment Due Date: July 17, 2017. Total Marks: 20. Previously we shared All Subjects Final term Papers solved by Moaaz.
CS506 Assignment No 3 Solution Spring 2017 |
CS506 Assignment Objectives:
- To build knowledge about how to develop basic dynamic web application in Java EE
- To write first Servlet in Java and communicate with Client using HTTP
- Install, configure and use Apache Tomcat Server for Java Web Application( For any query about the assignment, contact at CS506@vu.edu.pk )
CS506 Assignment No 3 Question
You are required to develop an HTML page using Microsoft Notepad that will work as a client to interact with Java Servlet. The HTML page should consist of “Patient Admit Card” containing basic HTML controls for taking information about Patient. The sample is as follows;
CS506 Assignment No 3 Question |
One Server side, you need to write Java Servlet named as “PatientServlet” which will dynamically respond to previously developed HTML form. Your servlet should check all HTML controls (i.e. text fields, radio buttons etc.) for non-empty values. In case when user has supplied all inputs, the servlet should display a response message back to user like;
Congrats Patient Admitted Successfully!
Thanks Mr. Muhammad Imran
(where Muhammad Imran is the name of patient)
Please Note: You need to install, configure, environment setup and test following software on your computer;
- Java SE (including JDK 8)
- Apache Tomcat Web Server 9.0 OR Java Servlet Libraries (servlet-api.jar and jspapi.jar)
CS506 Assignment No 3 Solution
CS506 Assignment No 3 solution idea :
Step - 1. Download and install xampp and jdk 7.0 then start the tomcat service from the control panel of xampp server.
create the form as mention in assignment file and make the form tag as below!
<form name="patientForm" method="post" action="patientServlet">
<form name="patientForm" method="post" action="patientServlet">
Step - 2. Open notepad and create a java file with name patientservlet.java compile it this will make a file name patientservlet.class.
Step - 3. copy html file and class file and paste in the tomcat directory and run.
to check null values use
if (patientname = isEmptey())
{
// type procedure here what you want.
}
else
{
//type procedure here what you want.}
patientservlet.java
package net.codejava.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/patientservlet")
public class patientservlet extends HttpServlet {
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// reading form fields
String patientname = request.getParameter("patientname");
PrintWriter writer = response.getWriter();
// build HTML code
String htmlRespone = "<html>";
htmlRespone += "<h2>Congratulation Mr: " + username + "<br/>";
writer.println(htmlRespone);
}
}
if You liked this Solution. Please subscribe us below or like us on Facebook.Thanks.
to check null values use
if (patientname = isEmptey())
{
// type procedure here what you want.
}
else
{
//type procedure here what you want.}
patientservlet.java
package net.codejava.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/patientservlet")
public class patientservlet extends HttpServlet {
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// reading form fields
String patientname = request.getParameter("patientname");
PrintWriter writer = response.getWriter();
// build HTML code
String htmlRespone = "<html>";
htmlRespone += "<h2>Congratulation Mr: " + username + "<br/>";
writer.println(htmlRespone);
}
}
if You liked this Solution. Please subscribe us below or like us on Facebook.Thanks.
Post a Comment