This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Struts and the fly likes struts module navigation problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts module navigation problem" Watch "struts module navigation problem" New topic
Author

struts module navigation problem

sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
HI ALL,

In my application i am using struts module concept..

In the Home page I am having two links

1.<html:link forward="Guest" styleClass="linksorangebold">Emergency login</html:link>

2.<html:link forward="NewPatient" styleClass="linksorangebold">Patient registration</html:link>

---------------------
here is my web.xml
------------------
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>config/pd</param-name>
<param-value>/WEB-INF/struts-pd-config.xml</param-value>
</init-param>

</servlet>

my struts-config.xml
------------------------
<global-forwards>
<forward
name="NewPatient"
path="/switch.do?page=/npregistration.do&prefix=/pd"/>

<forward
name="Guest"
path="emergencylogin.do"/>

</global-forwards>

<action-mappings>
<action
path="/emergencylogin"
parameter="/guestlogin.jsp"
type="org.apache.struts.actions.ForwardAction"/>

<action
path="/switch"
type="org.apache.struts.actions.SwitchAction"/>

</ation-mappings>

-----------------
struts-pd-config.xml
------------------------
<global-forwards>

<forward
name="NewPatient"
path="/patientregistration.jsp"/>
<forward
name="Home"
path="/switch.do?page=/home.do&prefix="/>

</global-forwards>

<action-mappings>

<action
path="/npregistration"
parameter="/patientregistration.jsp"
type="org.apache.struts.actions.ForwardAction"/>

<action
path="/switch"
type="org.apache.struts.actions.SwitchAction"/>


</action-mappings>
-----------------------------------

In home page when i click on emergency login ,emergency login is displayed,and same with the new Patient link.

In the New patient page i v link called
<html:link forward="Home" styleClass="linksorangebold">Home</html:link>

now when i click on Home from the new Patient page,Home page is displayed.
My problem is here,now when i am in home page and again click on emergency login link,following error is showing.

type Status report

message Invalid path /emergencylogin was requested

description The requested resource (Invalid path /emergencylogin was requested) is not available.

url showing in ths way...
http://localhost:8080/mystruts/pd/emergencylogin.do
instead of..
http://localhost:8080/mystruts/emergencylogin.do

where the misktake is?



All pages are directly benath WEB-INF

Help me out...

Regards
Sreenivas
sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
when i placed the code

<html:link forward="Home" styleClass="linksorangebold" module="pd">Patient registration</html:link> following error occured

SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding(TagUtils.java:446)
at org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding(TagUtils.java:329)
at org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:475)
at org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:334)
at org.apache.jsp.patientregistration_jsp._jspx_meth_html_link_0(org.apache.jsp.patientregistration_jsp:1012)
at org.apache.jsp.patientregistration_jsp._jspService(org.apache.jsp.patientregistration_jsp:714)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you look at the fine print in the documentation, it says that module is only valid if the link refers to an action instead of a forward. I had briefly put up a post suggesting this, but deleted it after I re-read the documentation.

Why all this convoluted business with a forward calling the switch action which in turn calls another action? why not just do this?

<html:link action="/home" module="">home</html:link>


Merrill
Consultant, Sima Solutions
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
Hi sreenivas
Merril is right and moreover you may also try
<forward
name="Guest"
path="/emergencylogin.do"/>

Please refer to the foll also.
http://mail-archives.apache.org/mod_mbox/struts-user/200507.mbox/%3Cdbv3mf$dtm$1@sea.gmane.org%3E


Regards,<br />Roshani
sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
Thanks Merrilli and Roshani.

I gone thru documentation and placed this code

<html:link forward="Home" styleClass="linksorangebold" module="">

its working fine..

Thanks again..
 
GeeCON Prague 2014
 
subject: struts module navigation problem