postheadericon 15. Assume that we have got three pdf files for the MCA-1 Syllabus, MCA-2 Syllabus and MCA-3 Syllabus respectively, Now write a Servlet which displays the appropriate PDF file to the client, by looking at a request parameter for the year (1, 2 or 3).


Index.html


<html>
<head>
<title>EX-15: WTAD : www.bipinrupadiya.com</title>
</head>
<body>
<center>
<FORM action="/Ex15/bipinrupadiya.blogspot.com">
Select MCA Syllabus : <select size=1 name="MCA">
<option value="MCA-1">MCA1</option>
<option value="MCA-2">MCA2</option>
<option value="MCA-3">MCA3</option>
</select>
<INPUT TYPE="SUBMIT" value="Show" >
</FORM>
</center>
</body>
</html>

Servlet


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


@WebServlet(
name="WTAD",
urlPatterns={"/Ex15","/bipinrupadiya.blogspot.com"}
)
public class ShowPDF extends HttpServlet
{
  public void doGet(HttpServletRequest request, HttpServletResponse response)throws
ServletException,IOException
{
String sem = request.getParameter("MCA");
response.setContentType("application/pdf");
response.sendRedirect("/"+sem+".pdf");
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
doGet(request,response);
}
}


NOTE: Put Three .pdf file on application's root directory (MCA-1.pdf, MCA-2.pdf, MCA-3.pdf)







3 comments:

rakib mama said...

Enjoy taking advantage of Motor Club of America's many health and travel discounts on services such as hotels, rental cars, vision, and dental. We have a network of the largest brands in those respective industries. Our perks will allow you to save hundreds on everday purchase items. Save hundreds of dollars a year by booking with any of our rental car agencies or hotel chains.
America auto club
Join Motor Club of America
Motor Club of America website
Motor Club
roadside assistance
MCA

siva said...

thanks for this excellent article! Just the scripts I've been looking for. a quick question:
how did you create those beautiful charts/graph in your post? many thanks!!!
Java training in Chennai | Java training institute in Chennai | Java course in Chennai

siva said...

thanks for this excellent article! Just the scripts I've been looking for. a quick question:
how did you create those beautiful charts/graph in your post? many thanks!!!

Java training in Chennai | Java training institute in Chennai | Java course in Chennai

Follow by Email

Blog Archive

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.