• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Help,Invalid path /jsp/viewinfo was requested?

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Your mother is a hamster and your father smells of tiny ads!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic