[go: up one dir, main page]

0% found this document useful (0 votes)
129 views7 pages

Practical 21

This document contains code for two Java servlet programs. The first program creates a servlet class called MSBTE_welcome that prints "Welcome to MSBTE" and maps it to the URL /Welco. The second program creates a servlet called pr21_2 that reads request parameters from an HTML form and writes them out, along with an HTML form to test it.

Uploaded by

Rani Powar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
129 views7 pages

Practical 21

This document contains code for two Java servlet programs. The first program creates a servlet class called MSBTE_welcome that prints "Welcome to MSBTE" and maps it to the URL /Welco. The second program creates a servlet called pr21_2 that reads request parameters from an HTML form and writes them out, along with an HTML form to test it.

Uploaded by

Rani Powar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Practical 21

Class : TYCM-SS Roll No : 42 Batch :


Name : Prathmesh Sikchi
VISHAL CHAVARE
------------------------------------------------------------------------------------------------------------------------------
Program 1:
JAVA PART:
package practical_servelet;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MSBTE_welcome extends GenericServlet {


String ms="";
public void service(ServletRequest req,ServletResponse rec)throws
ServletException,IOException
{
PrintWriter pw = rec.getWriter();
rec.setContentType("text/html");
pw.println("Welcome to MSBTE");
}
}
HTML PART:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>practical_servelet</display-name>
<servlet>
<servlet-name>Welcome</servlet-name>
<servlet-class>practical_servelet.MSBTE_welcome</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Welcome</servlet-name>
<url-pattern>/Welco</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

msbtebook.blogspot.com
Output :

msbtebook.blogspot.com
Program 2:
JAVA PART:
package practical_servelet;

import java.io.*;
import java.util.*;
import javax.servlet.*;
public class pr21_2 extends GenericServlet
{
public void service(ServletRequest request, ServletResponse response)
throws ServletException, IOException
{
PrintWriter pw = response.getWriter();
// Get enumeration of parameter names.
Enumeration e = request.getParameterNames();
// Display parameter names and values.
while(e.hasMoreElements())
{
String pname = (String)e.nextElement();
pw.print(pname + " = ");
String pvalue = request.getParameter(pname);
pw.println(pvalue);
}
pw.close();
}
}
HTML PART:
<html>
<body>
<center>
<form name="Form1" method="post"
action="http://localhost:8080/examples/servlet/PostParametersServlet">
<table>
<tr>
<td><B>Employee</td>
<td><input type=textbox name="e" size="25" value=""></td>
</tr>
<tr>
<td><B>Phone</td>
<td><input type=textbox name="p" size="25" value=""></td>
</tr>
</table>
<input type=submit value="Submit">
</body>
</html>

Output :
msbtebook.blogspot.com
VISHAL CHAVARE

msbtebook.blogspot.com
msbtebook.blogspot.com

You might also like