reference pdf files stored under WEB-INF/docs

C

Claudio

hello guys,

I have to create a jsp page that contains a link (trought a servlet)
to some pdf files stored under WEB-INF/docs (due to security reason).

I guess I should use Request.Dispatcher or something similar.
Someone has a snipplet or a part of code i could use ?

thanks
Claudio
 
N

Neill

Claudio said:
hello guys,

I have to create a jsp page that contains a link (trought a servlet)
to some pdf files stored under WEB-INF/docs (due to security reason).

I guess I should use Request.Dispatcher or something similar.
Someone has a snipplet or a part of code i could use ?

thanks
Claudio

Claudio,

You can have a Servlet, or JSP, which reads a parameter which identifies a
PDF, or other resource in WEB-INF, and forwards the request to the path
relative to WEB-INF, e.g. /WEB-INF/docs/new1.pdf

String pdf = req.getParameter("pdf");
String url = "/WEB-INF/docs/"+pdf;
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher
(resp.encodeRedirectURL(url));
dispatcher.forward(req, resp);
 
C

Claudio

thanks a lot! it worked!

claudio


Neill said:
Claudio,

You can have a Servlet, or JSP, which reads a parameter which identifies a
PDF, or other resource in WEB-INF, and forwards the request to the path
relative to WEB-INF, e.g. /WEB-INF/docs/new1.pdf

String pdf = req.getParameter("pdf");
String url = "/WEB-INF/docs/"+pdf;
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher
(resp.encodeRedirectURL(url));
dispatcher.forward(req, resp);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top