• Post Reply Bookmark Topic Watch Topic
  • New Topic

Forwading From a Servlet to a JSP  RSS feed

 
Mateen Dar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi.. i have a login Servelt loaded at the follwoing address

http://localhost:8080/LoginServet

and a simple jsp page at

http://localhost:8080/SimpleJSP

the webapps folder of my tomcat contains a folder for SimpleJSP and a folder for LoginServlet


i want to do the follosing when the login is succesfull .. i want the servelt to take me to the page SimpleJSP .. and if not take me to another JSP . hopw can i do that
i use the folllowing code

RequestDispatcher dispath=
getServletContext().getRequestDispatchr("/SimpleJSP");

dispatch.forward(request,response);


this will not work as SimpleJSP is npt within the LoginServlet folder.. where do i put the SimpleJSP folder to make the above code work. thnaks.
 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the webapps folder of my tomcat contains a folder for SimpleJSP and a folder for LoginServlet


From the looks of it you have your webapp structure all wrong...

you should have

webapp(folder):-SimpleJsp.jsp
+-WEB-INF
+-+-classes
+-+-+-<package folder e.g. servlets>
+-+-+-+-LoginServlet.java

this way your code should work just fine.

I would suggest you do some research on Wep app file structures as in the arrangements.

[ September 04, 2005: Message edited by: Ola Daniel ]
[ September 07, 2005: Message edited by: Ola Daniel ]
 
Mateen Dar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for u'r suggestion. its working fine. what do u mean my webapps deirectory is not in right. the tomcat 5.5 server is lo0ading the servlets and jsp fine. by the way is the WEB_INF and xml files not requires for a jsp
, like there required for servlets. thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each directory under webapps is considered by Tomcat to be a separate web application (context).
You can't forward from one context to another.
You will run into more issues down the road (sessions, shipping the app as a war file, etc..) if you don't re-structure it now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!