• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Context Root Problem

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...


 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hector Diaz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
reply
    Bookmark Topic Watch Topic
  • New Topic