try req.getPathInfo() in place of getServletPath() you can use getRequestURL() which will provide the requested URL that you are trying to rebuild.
Charlie > -----Original Message----- > From: Mark B. Indictor [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, February 27, 2002 12:24 PM > To: 'Tomcat Users List' > Subject: REPOST: Please HELP!: URL Mapping Problems in servlet > > > OK -- I'm having a related problem: > > I can hit my servlet with the following httpd.conf and > web.xml file setup > with these two URLs: > > http://hostname:8080/s2/sb/ > > And > > http://hostname/SiteBlocks/sb/ > > > From within the servlet, I am trying to reconstruct the URL. > I am using the > following code: > > ... > private String buildURL( HttpServletRequest req ) { > // Build a new absolute URL > StringBuffer url = new StringBuffer(); > url.append( req.getScheme() ); // http > url.append( "://" ); // http:// > url.append( req.getServerName() ); // http://hostname > url.append( ":" ); // http://hostname: > url.append( req.getServerPort() ); // http://hostname:80 > url.append( req.getServletPath() ); // > http://hostname:80/SiteBlocks/sb > return url.toString(); > } > ... > > Unfortunately, the URL this produces is either: > > http://hostname:8080/sb or http://hostname/sb, > > and not > > http://hostname:8080/s2/sb or http://hostname/SiteBlocks/sb > > as expected. > > Am I doing something wrong? If so, how can I get the desired result? > > > Thanks for any assistance! > > Here's an excerpt from my httpd.conf file: > > ... > <IfModule od_webapp.c> > WebAppConnection warpconnection warp localhost:8008 > WebAppDeploy examples warpConnection /examples/ > WebAppDeploy SiteBlocks warpConnection /SiteBlocks/ > </IfModule> > ... > > > Here's my entire web.xml file: > > <?xml version="1.0" encoding="ISO-8859-1"?> > > <!DOCTYPE web-app > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" > "http://java.sun.com/dtd/web-app_2_3.dtd"> > > <web-app> > <servlet> > <servlet-name> > SiteBlocks > </servlet-name> > <servlet-class> > S2Server > </servlet-class> > <init-param> > <param-name>resource</param-name> > > <param-value>/usr/local/jakarta-tomcat-4.0.2/webapps/SiteBlock > s/WEB-INF/Site > BlocksServer.properties</param-value> > </init-param> > </servlet> > > <servlet-mapping> > <servlet-name> > SiteBlocks > </servlet-name> > <url-pattern> > /sb > </url-pattern> > </servlet-mapping> > </web-app> > > - Mark > ====================================================== > Mark Indictor -- V.P. Engineering > [EMAIL PROTECTED] > <http://www.site2.com> > Phone:(310)451-3472 FAX:(240)220-6341 > http://keyserver.pgp.com/pks/lookup?op=get&search=0x8959F966 > ====================================================== > > > -----Original Message----- > From: Dave Ferguson [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, February 26, 2002 12:11 PM > To: Tomcat Users List > Subject: Re: servlet-mapping problem > > > This is basic stuff. It should work. What URL are you using > to invoke the > servlet? With no mapping the URL would be > http://server/servlet/warservlet. > If your mapping is > > <url-pattern>/blah</url-pattern> > > then the URL would be http://server/blah. Restart Tomcat to > be sure your > changes take effect. > > - df > > -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>