wood burning stoves*
The moose likes JSP and the fly likes How to generate a link in JSP to JSP file located into WEB-INF folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to generate a link in JSP to JSP file located into WEB-INF folder" Watch "How to generate a link in JSP to JSP file located into WEB-INF folder" New topic
Author

How to generate a link in JSP to JSP file located into WEB-INF folder

Clement Balay
Greenhorn

Joined: Dec 07, 2011
Posts: 2
HELLO,
My question is: is it possible to generate a link to a JSP situated into WEB-INF folder without use a servlet class.
Here my configuration:



Into index.jsp, I include /WEB-INF/jsp/main.jsp.
Into main.jsp, I have a link to about.jsp.
But how to generate this link ?
href="about.jsp" doesn't work, it is normal because folder WEB-INF is protected by tomcat.
I think i need to use pageContext.getServletContext(), but I don't know how to use it.

What do you think ?

Thanks for responses.

Clement
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

You can't link to anything inside the WEB-INF directory directly. In your situation I see two options:
1) Move these JSP files outside of the WEB-INF directory. Since you need to link to them, and therefore they need to be publicly available, this would be my choice.
2) Create a servlet entry with matching URL mapping entry inside your web.xml file. This will give the JSPs an "alias" that can be reached through the URL(s) specified in the URL mapping.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Clement Balay
Greenhorn

Joined: Dec 07, 2011
Posts: 2
thanks rob,
I used the second solution with this servlet class:



My urls are: /MySite/page?to=toto
 
Don't get me started about those stupid light bulbs.
 
subject: How to generate a link in JSP to JSP file located into WEB-INF folder
 
Similar Threads
[solved] problem writing href
Folder Structure
Eclipse WTP Directory Structure
not making the JSP pages visible using tomcat server
web application without WEB-INF