• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

struts application not using *.do

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

My Struts & Tiles application has a servlet mapping /action/*.Now with that mapping I have problems with formbeans.
My Struts Config is as follows
<?xml version="1.0" encoding="ISO-8859-1"?>
<struts-config>
<form-beans>
<form-bean name="results" type="formbean.inputformbean"/>
</form-beans>
<global-exceptions></global-exceptions>
<action-mappings>
<action path="/jsp/launch.jsp" type="action.DefaultAction" parameter="launch"/>
<action name="results" path="/jsp/results.jsp" type="action.ResultsAction" parameter="results" input="launch">
<forward name="success" path="results"/>
<forward name="failure" path="launch"/>
</action>
</action-mappings>
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<message-resources parameter="resources.application"/>
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/>
<set-property property="moduleAware" value="true"/>
<set-property property="definitions-parser-validate" value="true"/>
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>

I Also have a tile definition for the two actionmappings in my tile-defs.xml which is as follows
<definition name=".mainLayout" path="/layouts/template.jsp" controllerClass="controller.CustomTileController">
<put name="Title" value="Title" />
<put name="Top" value="/include/jsp/top.jsp" />
<put name="TopNav" value="/include/jsp/topnav.jsp" />
<put name="Left" value="/include/jsp/left.jsp" />
<put name="Crumb" value="/include/jsp/crumb.jsp" />
<put name="Content" value="/en/jsp/content/be_direct.jsp" />
<put name="Footer" value="/include/jsp/footer.jsp" />
</definition>
<definition name="launch" extends=".mainLayout">
<put name="title" value="Launc Title" />
<put name="Content" value="/en/jsp/content/launch.jsp" />
</definition>
<definition name="results" extends=".mainLayout">
<put name="title" value="Results Title" />
<put name="Content" value="/en/jsp/content/results.jsp" />
</definition>
My jsp page has a html:form
<html:form action="/jsp/results.jsp">

and I get a error Cant find Mapping for "/jsp/results" I get the impression that the form taglib removes the .jsp at the end of the form action path.Is there a way to solve this or circumvent this?? Any Insights would be appretiated.

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

Can you tell me what is servlet mapping in web.xml, when the request comes from *.now which actionservlet is called can you clear the servlet mapping for the *.now requests .may be you have not specified the servlet mapping for *.now requests

Best Regards
Pankaj
 
Sudeep Victor
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pankaj,

The mapping in the web.xml is /action/*
The url for my launch page would be
http://localhost:8080/strutsexample/action/jsp/launch.jsp
The launch.jsp needs to submit to
http://localhost:8080/strutsexample/action/jsp/results.jsp
but the <html:form> tag is not able to find the mapping for "/jsp/results.jsp"
It gives me the error cannot find mapping for "/jsp/results"

I tried to remove the .jsp from the mappings and it works fine. Hence the question as to how to resolve this

Sudeep
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What version of Struts are you using? I believe the prefix mappings are no longer allowed.
 
Sudeep Victor
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use the Struts 1.1 version. Does it say somewhere that prefix mappings are not allowed? :-(
If this is the case i'm in trouble.Also, now thinking of changing the code of the framework itself to suit my requirements.What do you people think about that?

Sudeep
 
Pankaj Narang
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi sudeep

I gorthe your problem, you go to web.xml there you find the mapping for *.do change it to *.jsp and your request will work out.

or copy the same again and change the *.do to *.jsp it will work

Best Regards
Pankaj
 
Sudeep Victor
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pankaj,
Thanks to you and Mark for providing insights.
I understand that by adding the *.jsp mapping in the web.xml it would work,but,I need a mapping like /action/* in my web.xml and with that mapping I was wondering if the form beans work.So far it dosnt work.
Mark says, that prefix mapping is not supported anymore.I did also look into the source of struts in the org.apache.struts.util.RequestUtils class and there I did find the reason.There is a method
getActionMappingName(String action) where this checking for a "." is done.The code for it as below
public static String getActionMappingName(String action) {
String value = action;
int question = action.indexOf("?");
if (question >= 0) {
value = value.substring(0, question);
}
int slash = value.lastIndexOf("/");
int period = value.lastIndexOf(".");
if ((period >= 0) && (period > slash)) {
value = value.substring(0, period);
}
if (value.startsWith("/")) {
return (value);
} else {
return ("/" + value);
}
}
I did comment out the place where the check for the "period" is made and now every thing seems allright,but, I wonder whether this has other impact.
I sure hope not.

Regards,
Sudeep
 
reply
    Bookmark Topic Watch Topic
  • New Topic