HTML FILE :
<html>
<body>
<h2><marquee behavior="alternate" speed="2"> GTU MCA SYLLABUS LIST </marquee></h2>
<form action="showpdf.com" method="GET">
<table border=1>
<tr>
<td>
Your Name :
<td>
<input type="text" name="name">
<tr>
<td>
Select Pdf :
<td>
<select name="sem">
<option value="1">MCA Sem - 1</option>
<option value="2">MCA Sem - 2</option>
<option value="3">MCA Sem - 3</option>
</select>
<tr>
<td colspan=2 align="center">
<input type="submit" value="SHOW">
</table>
</form>
</body>
</html>
SERVLET CLASS :
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class pro15 extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
res.setContentType("application/pdf");
PrintWriter out=res.getWriter();
String name=req.getParameter("sem")+".pdf";
res.sendRedirect(name);
}
}
i have a existing pdf file in which i want to open a pdf file by using a servlet code.
ReplyDeleteMy question is where i put a pdf file?
Can i put pdf file in (classes) folder which is to be lie in the WEB-INF?
plz help me
ReplyDeleteout side of WEB-INF file and pdf file name should be 1.pdf , 2.pdf , 3.pdf
ReplyDelete