Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forward from jsp to servlet in a package

 
Peter Straw
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have just moved all my servlet classes from the default classes folder into their own packages, but now the jsp files cannot find them!
Please can you tell me what I need to change to make this work:
<jsp:forward page="/servlet/myServlet" />
to find myServlet in the 'peter.myPackage' folder.
Many thanks
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to edit your web.xml and update the servlet-class elements to point to the new locations.
 
Peter Straw
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou very much Chris, that works well for forwarding posts etc.
The problem now is that simple 'bean' classes (which just hold data in an object) can't be found from inside the JSP. I have put these into packages too. Any idea how I can get hold of these from the jsps?
 
Peter Straw
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please ignore my last post! It's all sorted by using the full path to the class.
Thanks.
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also declare imports in JSP so that you do not need to fully qualify every classname.
Example:

[ December 20, 2002: Message edited by: Chris Mathews ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic