aspose file tools*
The moose likes Servlets and the fly likes Context Root Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Context Root Problem" Watch "Context Root Problem" New topic
Author

Context Root Problem

Hector Diaz
Greenhorn

Joined: Oct 27, 2012
Posts: 2
Hi,

I have a small app called myapp with a link a other page jsp:


when I deploy this app with jboss locally this work sucessfully


but when this app is in a server (ie: htpp://server/myapp/index.jsp) this link in a jsp doesn´t work, but when i change it for


works fine again.
I don't understant what is the reason, but I need that this application to be independent of the server...


K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1958
    
    7

Welcome to the Ranch Hector.

The context root in servlet and JSP can be retrieved by


Everything after that is relative to this context root. So ideally you shouldn't need to include the "/" in front of other.jsp in order to trigger the link.

When you do testing, the effect on a server or locally should be the same.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Because Java code should never be used in a JSP, the proper means to get the context path in a JSP is ${pageContext.request.contextPath}

You could also create URLs in JSPs with the JSTL <c:url> tag, which prepends the context path correctly.

See the JspFaq for more info.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Hector Diaz
Greenhorn

Joined: Oct 27, 2012
Posts: 2
K. Tsang wrote:Welcome to the Ranch Hector.

The context root in servlet and JSP can be retrieved by


Everything after that is relative to this context root. So ideally you shouldn't need to include the "/" in front of other.jsp in order to trigger the link.

When you do testing, the effect on a server or locally should be the same.


Thanks a lot for your reply...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Context Root Problem
 
Similar Threads
Configuring http://localhost in Tomcat/Eclipse
Problem Invoking Servlet thru Proxy Server
Configuring http://localhost in Tomcat/Eclipse
response.sendRedirect();jsp:forward;<c:redirect>
Servlet Mapping