Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting 404 when i forward request using request dispetcher

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • 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
 
Prashant Hurria
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • 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.
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the tag "<servlet>" closed? Up there in the code you posted still opened...
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • 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: 762
  • Mark post as helpful
  • send pies
  • 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
  • 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: 762
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic