• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Clement Balay
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Clement Balay
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks rob,
I used the second solution with this servlet class:



My urls are: /MySite/page?to=toto
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic