Saturday 22 June 2013

12. Write a Servlet to display parameters available on request.

WTAD Practical - 12
Write a Servlet to display parameters available on request.
index.html


<HTML>
<HEAD>
<TITLE>WTAD.practical-12 @iAmLearningHere </TITLE>
</HEAD>
<BODY bgcolor="YellowGreen">
<h3>Display parameters available on request.</h3>
<hr>
<form name="f1" action="display" method="get" >
<!-- Enter Three Parameters Here -->
Source Name:<input type="text" name="nm"/><br />
Subject 1 &nbsp;&nbsp;&nbsp; : <input type="text" name="sub1" /><br />
Subject 2 &nbsp;&nbsp;&nbsp; : <input type="text" name="sub2" /><br />

<input type="submit" value="Send Parameters" />
</form>
</BODY>
</HTML>


WEB-INF/web.xml
<web-app>
<servlet>
<servlet-name>s12</servlet-name>
<servlet-class>RequestParameters</servlet-class>
</servlet>
<!-- Servlet Mapping -->
<servlet-mapping>
<servlet-name>s12</servlet-name>
<url-pattern>/display</url-pattern>
</servlet-mapping>
</web-app>


WEB-INF/classes/RequestParameters.java


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

public class RequestParameters extends HttpServlet
{
public void doGet( HttpServletRequest request,HttpServletResponse response ) throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<HTML>" + 
"<HEAD><TITLE>WTAD.practical-12 @iAmLearningHere</TITLE></HEAD>" +
"<body bgcolor=YellowGreen>");
out.println("<h3>Reading Three Request Parameters </h3><br>");

out.println("Name :: " + request.getParameter("nm") + "<br>");
out.println("Subject1 :: " + request.getParameter("sub1") + "<br>");
out.println("Subject2 ::" + request.getParameter("sub2") + "<br>");

out.println("</body></HTML>");

}
}

Preview



How to Run?
> Start Apache Server
> Start localhost and open program folder
> Enter details in three text box and submit

For all WTAD programs wtad-pra cticals.html
To get all programs in your inbox.Enter your email

Kindly Bookmark and Share it:

0 comments :

Post a Comment

Any Query ? any suggestion ? comment here

 

Recent Post

Recent Comments

© 2010 IamLearningHere Template by MBT