Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help,Invalid path /jsp/viewinfo was requested?

 
lyo Yashnoo
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone :
I write a jsp page using struts.In jsp,I write:"<a href="viewinfo.do?category=<bean:write name="categ" property="category"/>&id=<bean:write name="map" property="id"/>"/><bean:write name="map" property="name"/></a>"
I use this code to get tow parameter.When I move mouse to the hyperlink the statusbar display:"http://localhost:3030/myweb/jsp/viewinfo.do?category=birds&id=3".It's right.But when I click it Tomcat report error:
////////////////////////////////////////////////////////////////
HTTP Status 400 - Invalid path /jsp/viewinfo was requested
--------------------------------------------------------------------------------
type Status report
message Invalid path /jsp/viewinfo was requested
description The request sent by the client was syntactically incorrect (Invalid path /jsp/viewinfo was requested).

--------------------------------------------------------------------------------
In my struts-config.xml there is action for the request indeed.
/////////////////////struts-config.xml///////////////////////////////////
........................................................
<action path="/viewinfo" type="lyo.hotmail.shopping.Showinfo" input="filemiss.jsp">
<forward name="success" path="/jsp/viewinfo.jsp"/>
</action>
Even I add the "<forward name="viewinfo" path="/viewinfo.do"/>" it can't work too. :roll:

Finally,I change the jsp code to ":"<a href="myweb/jsp/viewinfo.do?category=<bean:write name="categ" property="category"/>&id=<bean:write name="map" property="id"/>"/><bean:write name="map" property="name"/></a>"
It also can't work property and the error is the same as before.
Why?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the looks of it, your webapp root is /myweb, and the action is mapped to /viewinfo, so the link should point to /myweb/viewinfo.do not to /myweb/jsp/viewinfo.do. You could achieve this with minimal change:I would strongly discourage this though. The problem is that this URL is relative to the request path. In an MVC application, your JSP should not make assumptions about the request path: after all, the Struts configuration file can map all manner of requests to your JSP. Making assumptions about the path introduces hidden dependencies that will come back to haunt you sooner or later.
You need an absolute path. Sticking in one by hand:Is bad practice as well, because you unnecessarily hardcode where the web-app root is going to be. Use the link tag instead:If putting name and category in a Map is too much trouble, then you can use <html:rewrite>:Both the link and rewrite tags will prepend the path you give by the web-app root path, and also add the .do suffix (or whatever extension you have mapped to the Struts ActionServlet).
- Peter
[ October 11, 2003: Message edited by: Peter den Haan ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic