WTAD Practical - 15
Write a Servlet to display parameters available on request.
index.html
WEB-INF/classes/Syllabus.java
Preview
Write a Servlet to display parameters available on request.
index.html
<HTML>
<HEAD>
<TITLE>WTAD.practical-15 @iAmLearningHere </TITLE>
</HEAD>
<BODY bgcolor="YellowGreen">
<h3>DISPLAY Syllabus in pdf</h3>
<hr>
<form name="f1" action="display" method="get" >
MCA-1<br>
MCA-2<br>
MCA-3<br>
<input type="text" name="MCA" value="" />
<input type="submit" value="Show Syllabus" />
</form>
</BODY>
</HTML>
WEB-INF/web.xml<HEAD>
<TITLE>WTAD.practical-15 @iAmLearningHere </TITLE>
</HEAD>
<BODY bgcolor="YellowGreen">
<h3>DISPLAY Syllabus in pdf</h3>
<hr>
<form name="f1" action="display" method="get" >
MCA-1<br>
MCA-2<br>
MCA-3<br>
<input type="text" name="MCA" value="" />
<input type="submit" value="Show Syllabus" />
</form>
</BODY>
</HTML>
<web-app>
<servlet>
<servlet-name>s15</servlet-name>
<servlet-class>Syllabus</servlet-class>
</servlet>
<!-- Servlet Mapping -->
<servlet-mapping>
<servlet-name>s15</servlet-name>
<url-pattern>/display</url-pattern>
</servlet-mapping>
</web-app>
<servlet>
<servlet-name>s15</servlet-name>
<servlet-class>Syllabus</servlet-class>
</servlet>
<!-- Servlet Mapping -->
<servlet-mapping>
<servlet-name>s15</servlet-name>
<url-pattern>/display</url-pattern>
</servlet-mapping>
</web-app>
WEB-INF/classes/Syllabus.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class Syllabus extends HttpServlet
{
private int count = 0;
public void doGet( HttpServletRequest request,HttpServletResponse response ) throws ServletException,IOException
{
// set contenttpe as pdf
response.setContentType("application/pdf");
PrintWriter out=response.getWriter();
String semester = request.getParameter("MCA");
response.sendRedirect(semester + ".pdf");
}
}
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class Syllabus extends HttpServlet
{
private int count = 0;
public void doGet( HttpServletRequest request,HttpServletResponse response ) throws ServletException,IOException
{
// set contenttpe as pdf
response.setContentType("application/pdf");
PrintWriter out=response.getWriter();
String semester = request.getParameter("MCA");
response.sendRedirect(semester + ".pdf");
}
}
How to Run?
> Start Apache Server
> Put 3 pdf file named MCA-1, MCA-2, MCA-3
> Start localhost and open program folder
> Enter File name and submit
> Start Apache Server
> Put 3 pdf file named MCA-1, MCA-2, MCA-3
> Start localhost and open program folder
> Enter File name and submit
1 comments :
hello, today as always your post is lovely that I liked it and I am waiting for your new works in future, good luck to all of you.
digital marketing services in delhi