Coding Java10
Coding Java10
DATE:21.9.10
Aim:
To create a java server side application using servlet and invoke it from a HTML
client .
Hardware requirements:
Intel pentium Processor IV
128mb RAM
Software requirements:
Jdk1.6.0
Algorithm:
1. Create a client using HTML It get the username and password from
the user. When you submit the form it invoke the servlet.
2. Create a server using servlet It receive the data from client and display
the result to the client.
3. Deploy the servlet in to the server.
4. Run the client and server application . When you submit the client
form it invoke the servlet and the server display the result to the client.
INVOKING SERVLET FROM HTML
HTML CODING:
<html>
<head><title>WELCOME TO MY SERVLET</title></head>
<body>
SERVLET CODING:
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
public class HelloServlet extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res)throws
ServletException,IOException
{
PrintWriter out=res.getWriter();
res.setContentType("text/html");
String name=req.getParameter("name");
String pwd=req.getParameter("pwd");
out.println("<html>");
out.println("<body>");
out.println("WELCOME!!!!!!" + name);
out.println("</html>");
out.println("</body>");
out.close();
}
}
OUTPUT:
RESULT:
Thus the servlet has been deployed and invoked from the HTML client.