aspose file tools*
The moose likes Struts and the fly likes Help,Invalid path /jsp/viewinfo was requested? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Help,Invalid path /jsp/viewinfo was requested?" Watch "Help,Invalid path /jsp/viewinfo was requested?" New topic
Author

Help,Invalid path /jsp/viewinfo was requested?

lyo Yashnoo
Ranch Hand

Joined: Sep 15, 2003
Posts: 50
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

Joined: Apr 20, 2000
Posts: 3252
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 ]
 
wood burning stoves
 
subject: Help,Invalid path /jsp/viewinfo was requested?