Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Getting 404 when i forward request using request dispetcher

 
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have written a servlet which forward the request to jsp page, but i am getting 404 error code. Can anybody help me solving this issue.

Bellow is my servlet mapping in DD



Bellow is my servlet code.



And below is my JSP which is in the application root folder.



I am sending request from the same jsp and forwarding the request to the same jsp i am fetching some data and putting in the request attribute to display it on jsp.

Console
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems simple and Should work.
I tried on my system and it did.
The only way you get a 404 here is when the folder structure /ExcelUploadPOC/WebContent/upload.jsp
is under web-inf i.e. you have places your JSP
here: <Tomcat-Dir> \webapps\<WebApplicationName>\WEB-INF\ExcelUploadPOC/WebContent/upload.jsp
put it here it will work:
<Tomcat-Dir> \webapps\<WebApplicationName>\ExcelUploadPOC/WebContent/upload.jsp

Let me know if it solves the issue.
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the tag "<servlet>" closed? Up there in the code you posted still opened...
 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hebert Coelho wrote:Is the tag "<servlet>" closed? Up there in the code you posted still opened...



yeah the tag is closed, i just missed it while copy on the forum.
 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prashant Hurria wrote:It seems simple and Should work.
I tried on my system and it did.
The only way you get a 404 here is when the folder structure /ExcelUploadPOC/WebContent/upload.jsp
is under web-inf i.e. you have places your JSP
here: <Tomcat-Dir> \webapps\<WebApplicationName>\WEB-INF\ExcelUploadPOC/WebContent/upload.jsp
put it here it will work:
<Tomcat-Dir> \webapps\<WebApplicationName>\ExcelUploadPOC/WebContent/upload.jsp

Let me know if it solves the issue.



Hi Prashant,

Actually the JSPs are not underthe WEB-INF folder. I can access the jsp using below url

http://localhost:7001/ExcelUploadPOC/upload.jsp

I thought it has the problem with build, but even after cleaning, rebuild, restarting the weblogic, restarting the IDE, restarting the computer issue is still persist.
 
Prashant Hurria
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tested it on Tomcat. I have seen people facing strange issues on JBoss,Weblogic and most of the time it turns out to be problems like using \ insted of / and other similar things. I will ask a friend who faced a similar issue and will get back to you. In the meanwhile you can google the problem with Weblogic as additional keyword (I am sure you would have done already.)
 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya i have already done the google exercise... Currently i am setting attributes in session and using response.sendRedirect(String). And its working fine as a temperory workaround.
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic