• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How can I get to the root of the application.

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have got problem, and I really need your help ^^.

Let's assume that the user is at this page:
http://localhost:8080/WebIndex/test/student/log.jsp

Now I would like to redirect him to the
http://localhost:8080/WebIndex/index.jsp

how can I do it?

I don't want to write something like this:

becouse this address is temporary of course. I was trying with RequestDispatcher:

but it is opening this page:
http://localhost:8080/WebIndex/test/student/index.jsp


 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess you could use request.getContextPath() to build a path to the given resource:


Not sure, if its the best solution, though.
 
Tom Kowalski
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
// ok
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the following code: should get you to the root of the server: http://localhost:8080/index.jsp

HF page 136, relative paths:
if the path starts with the forward slash / then the container builds the complete URL relative to the web container itself
if you do NOT provide the forward slash / then the container builds the URL relative to the original request URL

the spec does not say anything about the forward slash!!!

maybe you do not use the forward slash

enjoy!
 
Sheriff
Posts: 67750
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

Omer Haderi wrote:maybe you do not use the forward slash


Yes. He does. In fact, the answer prefixing the context path is the correct answer.
 
What's that smell? Hey, sniff this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic