Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

confused with forwarding request

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a jsp which will be submitted in to a first servlet which forwards the request to a second servlet.

I tried this on my home and in my office it gives two different results.

in my office when i call req.getRequestURL() in my second servlet it will give me the http://localhost:8080/processparam where i obtained the request dispather as req.getRequestDispatcher("processparam") in my first servlet.but same code when i run in my home instead of this it displays http://localhost:8080/test the url which will be invoked when i submit the JSP page for my first servlet test why is this happening it is the same code. what could be the reason.

and one more thing in my web.xml i have this

<servlet>
<servlet-name>contextparam</servlet-name>
<servlet-class>com.scwcd.test</servlet-class>
</servlet>

<servlet>
<servlet-name>processparam</servlet-name>
<servlet-class>com.scwcd.testparam </servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>contextparam</servlet-name>
<url-pattern>/contextparam/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>processparam</servlet-name>
<url-pattern>/processparam/*</url-pattern>
</servlet-mapping>

in my test.java file i will get the requestdispatcher and forward the request. once i get this URL http://localhost:8080/test on browser after submitting the JSP file in my office when i change url to http://localhost:8080/test/1/2/3 it works fine but same thing in my home system it throws stack overflow exception if i comment requestdispatcher code it works fine

I am REALLY CONFUSED WITH THIS FROM 3 DAYS can any body help me in solving this issue
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

why is this happening it is the same code. what could be the reason.


Different container ? How did you set the web-app tag in your web.xml ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Here is your problem. You are getting a dispatcher using a path relative to the current request. Which means that "/contextparam/processparam" will be called, which goes back to your first servlet again. And this loops until the stack explodes. You should use a path relative to the context instead :
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply.

yes it is displaying the URL as /contextparam/processparam on the console but it is working fine in my office system but not in my home system

How did you set the web-app tag in your web.xml ? i just copied a web.xml file from examples folder and put my code with in <web-app> tag nothing else i did.

Please let me know if i am missing any thing.

Thanks
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

what version of tomcat should we use for SCWCD 1.5 ? i checked SCWCD links in the forum and found free server tomcat 5.5 but is there any specific server version to be used.

Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

put my code with in <web-app> tag nothing else i did.


If you are using different containers at home and at work, this may give you different results. I think that you should first declare the web-app tag properly to avoid the confusion. Check this FAQ.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I tried putting the extra elements for <web-app ...> from the specified location now it is giving other exception. can any body give me a correct
web.xml code with web-app...> and doc type elements it will be very help full

Thanks
[ April 09, 2008: Message edited by: raja ram ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

can any body give me a correct web.xml code with web-app...> and doc type elements it will be very help full


You still haven't told us which container you are using.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christophe Verre,

Thank you so much for all the replys and help. i am using tomcat on the index page it displays Apache Tomcat/4.1.36-LE-jdk14 if i am not wrong it is tomcat 4.1 correct.

Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat 4.1 ? This is the SCWCD forum. Are you studying for SCWCD ? If so, you should be using at least Tomcat5.x.
Tomcat 4.x only supports Servlets 2.3 :

Are you using Tomact4.1 both at home and at work ?
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I am studying for SCWCD 1.5 only,ok i'll dowload tomcat 5.5 from the SACWCD links .

Yes I am using tomcat 4.1 in both the places.

Thanks
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply I have installed Tomcat 5.0.28 in both the places and all my problems are solved.

Thanks
 
I can't renounce my name. It's on all my stationery! And hinted in this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!