/**
* Author: SHADOW
* Date: 3 FEB 2012
* Description:create a servlet that processes two values obtained from a
Web page and displays a response based on those values.
*
*/
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Label extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
/**
* Indicate the content type (for example, text/html),
* being returned by the response
*/
response.setContentType("text/html");
/**
* Retrieve an output stream to use to send data to the client
*/
PrintWriter out = response.getWriter();
/**
* Get the user input from the form
*/
String SenderName1 = request.getParameter("SenderName");
String SenderStrtAddr1 = request.getParameter("SenderStrtAddr");
String SenderCityZip1 = request.getParameter("SenderCityZip");
String ReceiverName1 = request.getParameter("ReceiverName");
String ReceiverStrtAddr1 = request.getParameter("ReceiverStrtAddr");
String ReceiverCityZip1 = request.getParameter("ReceiverCityZip");
String Destination1 = request.getParameter("destination");
/**
* Construct the HTML response : start with the header
*/
out.println("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>");
out.println("<HTML>");
out.println("<HEAD><TITLE>ShippingLabelForm</TITLE></HEAD>");
out.println("<BODY bgcolor='#1E90FF'>");
out.println("<TABLE>");
out.println("<tr>");
out.println("<td>");
/**
* Add the sender information
*/
out.println("<B>From:-</B>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println("<p>" + SenderName1 + "</p>");
out.println("<p>" + SenderStrtAddr1 + "</p>");
out.println("<p>" + SenderCityZip1 + "</p>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
/**
* Add the image
*/
out.println("<TD align='right' valign='top'>");
out.println("<IMG SRC = '/" + Destination1 + "'" + "alt='" + Destination1 + "'>");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
/**
* Add the receiver information
*/
out.println("<BR><BR><B>To:-</B>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("<p>" + ReceiverName1 + "</p>");
out.println("<p>" + ReceiverStrtAddr1 + "</p>");
out.println("<p>" + ReceiverCityZip1 + "</p>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("</tr>");
/**
* End with the footer
*/
out.println("</table>");
out.println("</body>");
out.println("</html>");
} // end-doPost
}
* Author: SHADOW
* Date: 3 FEB 2012
* Description:create a servlet that processes two values obtained from a
Web page and displays a response based on those values.
*
*/
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Label extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
/**
* Indicate the content type (for example, text/html),
* being returned by the response
*/
response.setContentType("text/html");
/**
* Retrieve an output stream to use to send data to the client
*/
PrintWriter out = response.getWriter();
/**
* Get the user input from the form
*/
String SenderName1 = request.getParameter("SenderName");
String SenderStrtAddr1 = request.getParameter("SenderStrtAddr");
String SenderCityZip1 = request.getParameter("SenderCityZip");
String ReceiverName1 = request.getParameter("ReceiverName");
String ReceiverStrtAddr1 = request.getParameter("ReceiverStrtAddr");
String ReceiverCityZip1 = request.getParameter("ReceiverCityZip");
String Destination1 = request.getParameter("destination");
/**
* Construct the HTML response : start with the header
*/
out.println("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>");
out.println("<HTML>");
out.println("<HEAD><TITLE>ShippingLabelForm</TITLE></HEAD>");
out.println("<BODY bgcolor='#1E90FF'>");
out.println("<TABLE>");
out.println("<tr>");
out.println("<td>");
/**
* Add the sender information
*/
out.println("<B>From:-</B>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println("<p>" + SenderName1 + "</p>");
out.println("<p>" + SenderStrtAddr1 + "</p>");
out.println("<p>" + SenderCityZip1 + "</p>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
/**
* Add the image
*/
out.println("<TD align='right' valign='top'>");
out.println("<IMG SRC = '/" + Destination1 + "'" + "alt='" + Destination1 + "'>");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
/**
* Add the receiver information
*/
out.println("<BR><BR><B>To:-</B>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("<td>");
out.println("<p>" + ReceiverName1 + "</p>");
out.println("<p>" + ReceiverStrtAddr1 + "</p>");
out.println("<p>" + ReceiverCityZip1 + "</p>");
out.println("</td>");
out.println("<td>");
out.println("</td>");
out.println("</tr>");
/**
* End with the footer
*/
out.println("</table>");
out.println("</body>");
out.println("</html>");
} // end-doPost
}
No comments:
Post a Comment