This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Working with JSP & Servlet paths  RSS feed

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, I'm developing a web application under Tomcat 5 and I'm facing a problem with paths to JSPs and servlets (I fear it's kinda stupid, but I cannot get out of it).
Basically the web app is working without problems, I got it deployed under my Tomcat and I surf it pointing the browser at http://localhost:8080/<WebAppContext>/index.jsp and so on. When it comes to deploying the webapp in production mode, I can surf it at the address http://www.myweburl.com/index.jsp and so on. I would like to point out that the production server is hosted by a web farm, so I do not have total control over any aspect of the deployment environment. Please notice also that while running locally I have to specify the webapp context, while when running in production mode I have not.
I've read the JSP faq about URLs here on JavaRanch, and I'd say it seems quite clear, but instead I feel like I'm missing something.
In JSP and servlet code I'm managing URLs and forwards like this :

in JSP :



in Servlets :



suppose JSPName.jsp is located in the root directory.

The problem is that while in production mode when I run the servlet it seems to work right, when I run the same servlet locally I get a 404 because the servlet tries to forward me at the page :



i.e. appending twice the context path.
I fear I can't adjust the code to let it run locally, since it will not work in production mode. Again, I feel I'm missing something, how should I code links and forwards to let it run both locally and remotelly, i.e. with and without an explicit context path ? What am I missing ?

Thanks all for kind reply and sorry for such a huge post for such a stupid problem.
[ July 02, 2008: Message edited by: Bear Bibeault ]
 
Author and ninkuma
Marshal
Posts: 66801
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When request dispatching, you not include the context path. Dispatching is local to the current context, so it doesn't get specified.
 
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Matteo Di Furia welcome to Javaranch,
as said by Bear, the path is always relative to the current context.
And it does not make any difference whether its development or production.

Thanks all for kind reply and sorry for such a huge post for such a stupid problem.


And no question is stupid, every question has a value and an answer of course .



Hope this helps .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!