practical 14 java

 avatar
Rohit143
plain_text
3 years ago
1.0 kB
17
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
       <title>Login form</title>
</head>
<body>
    <form action="welcome" method="get">  
    Enter your name: <input type="text" name="name"><br>  
    <input type="submit" value="login">  
    </form>
</body>
</html>

____________________________________

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

public class Practical14 extends HttpServlet {
    public void doGet(HttpServletRequest req,HttpServletResponse res)  throws ServletException,IOException{

     res.setContentType("text/html");
     PrintWriter pw = res.getWriter();
     String name =req.getParameter("name");
     pw.println("Welcome "+name);
     pw.close();
 }   
}
_____________________________________
<web-app>

<servlet>
<servlet-name>practical14</servlet-name>
<servlet-class>Practical14</servlet-class>

</servlet>

<servlet-mapping>
<servlet-name>practical14</servlet-name>
<url-pattern>/welcome</url-pattern>
</servlet-mapping>

</web-app>