Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

calling servlet from JSP

  Asked By: Adella    Date: Nov 04    Category: Java    Views: 1027
  

I have a servlet which open and display a PDF file. However, I want to this PDF
display inside my JSP page. I don't know how to call this servlet from my JSP
page to be able to display PDF inside JSP page.
I tried this code
<%
String url = "http://localhost:8080/portal/PDFDisplayServlet";
RequestDispatcher rd = application.getRequestDispatcher(url);
rd.forward(request,response);
%>
but I've got this error
An exception occurred processing JSP page /LMSPortal.jsp at line
":RequestDispatcher rd = application.getRequestDispatcher(url);"

I also tried <jsp:include page="/PDFDisplayServlet"></jsp:include> but on the
page this message was appeared "The requested resource
(/portal/PDFDisplayServlet) is not available "

Could you please advise me?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Sean Grant     Answered On: Nov 04

Your second method is fine just make sure your web.xml has the same url mapping for your servlet  "/PDFDisplayServlet".

 
Didn't find what you were looking for? Find more on calling servlet from JSP Or get search suggestion and latest updates.




Tagged: