This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File root config problem

 
Anthony Smith
Ranch Hand
Posts: 285
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say I got a server http://mydomain.com
Annd I have a page http://mydomain.com/forms/new/add.jsp that posts to a servlet
http://mydomain.com/ProcessForm
In my servlet I have
getServletContext().getRequestDispatcher(viewTemplate).forward(req, res);
where viewTemplate = "/thankyou.jsp"
Now thankyou.jsp is located here http://mydomain.com/forms/new/thankyou.jsp
Now if I user that forward it tries to look for:
http://mydomain.com/thankyou.jsp
I do nto want to hardcode the /forms/new inside of my viewTemplate, becasue the names of the paths might change, but the structure will still be the same.
How do I code it where it knows to forward to http://mydomain.com/forms/new/thankyou.jsp
and not to http://mydomain.com/thankyou.jsp without hardcoding.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check your other post

http://www.coderanch.com/t/357223/Servlets/java/Why-RequestDispatcher-null

so, the answer is to use:

request.getRequestDispatcher()

and remove the leading '/'
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic