• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem resolving relative urls in jsp/servlet  RSS feed

 
preeti dengri
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
I am stuck in the concept of forwarding a request from a servlet to a jsp page, which uses <jsp:useBean> tag,and is unable to load the class required.to simplify things here how it is
1.I have quick-search.html in c:\tomcat\webapps\travel
2.This submits the form to a servlet in c:\tomcat\webapps\webclient\servlets\coreservlets (and class in the default dir under c:\tomcat\webapps\root\web-inf\classes)by
<form name="form1" method="post" action="/servlet/coreservlets.Travel">
3.this servlet after checking the input forwards to a jsp page through a method gotoPage used for forwarding requests
gotoPage("/travel/BookFlights.jsp",request,response);
4.inside the above jsp we have
<jsp:useBean id="customer" class="coreservlets.TravelCustomer" scope="session" />
this particular jsp page is unable to laod the class TravelCustomer which is also at the same location as other servlets inside coreservlets package.
i am stuck as to when we have to use paths relative to servlet dir or to the document root and what is the best way to place all files (at places other than the default dirs under tomcat)
like inside <@ page import =" ----relative to what???"> and <jsp:useBean id="customer" class="---relative to what???">
appreciate any help
preeti
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow,
This looks like you are trying to cross webapps. When you cross a webapp, don't use a URL fragment, use the full URL. Anytime you are trying to access a resource in the same webapp, if the fragment starts with / it is relative to the root of the application you are in. If it dose not start with a / then it is relative to the location of the resource(html or jsp file) that it is in.

------------------
Hope This Helps
Carl Trusiak, SCJP2
 
preeti dengri
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Carl,
Thanx that is a very basic thing i need to know.But even that didn't make my application running.
The jsp page, i am calling a bean from ,is not able to load the class file .It works fine if i put the BookFlights.jsp in the default dir under tomcat i.e (c:/tomcat/webapps/root/jsp) and calls the class file in this way i.e
<jsp:useBean id="customer" class="coreservlets.TravelCustomer" scope="session" />
but calling the class in the above way from http://localhost:8080/travel/BookFlights.jsp by putting BookFlights.jsp in c:/tomcat/webapps/travel is not working.
the path to coreservlets package is correctly placed in classpath and the classes are in the default dir.
Waiting for help.
preeti
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!