Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Struts newbie question

Reply
Thread Tools

Struts newbie question

 
 
in_dv
Guest
Posts: n/a
 
      11-08-2006
Hello All,

I am a newbie to struts. I am trying to get a simple example working
which I found on jakarta struts tutorial.

When I click on a link, I expect it to transfer to TestAction.jsp page
, but I can see it changes to TestAction.do and I get "Page Cannot be
found" HTTP 404 error.

Followign are the entries in struts-config.xml file

<action
path="/TestAction"
type="devika.TestAction">
<forward name="testAction" path="/TestAction.jsp"/>
</action>

following is entry in .jsp file

<html:link page="/TestAction.do">Test the Action</html:link>

Kindly please help me

D

 
Reply With Quote
 
 
 
 
Tim Slattery
Guest
Posts: n/a
 
      11-08-2006
"in_dv" <(E-Mail Removed)> wrote:

>Hello All,
>
>I am a newbie to struts. I am trying to get a simple example working
>which I found on jakarta struts tutorial.
>
>When I click on a link, I expect it to transfer to TestAction.jsp page
>, but I can see it changes to TestAction.do and I get "Page Cannot be
>found" HTTP 404 error.
>
>Followign are the entries in struts-config.xml file
>
><action
> path="/TestAction"
> type="devika.TestAction">
> <forward name="testAction" path="/TestAction.jsp"/>
> </action>
>
>following is entry in .jsp file
>
><html:link page="/TestAction.do">Test the Action</html:link>


That link causes the Struts front end to search the struts-config.xml
file and find the "action" you've reproduced above. That "action"
element tells it to transfer control to "devika.TestAction.class".
Presumably that class will eventually pass control to the
TestAction.jsp page (by coding something like:

mapping.findForward("testAction");

--
Tim Slattery
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
richardsosborn@gmail.com
Guest
Posts: n/a
 
      11-08-2006
Your case is different in the forward and Struts Config.


in_dv wrote:
> Hello All,
>
> I am a newbie to struts. I am trying to get a simple example working
> which I found on jakarta struts tutorial.
>
> When I click on a link, I expect it to transfer to TestAction.jsp page
> , but I can see it changes to TestAction.do and I get "Page Cannot be
> found" HTTP 404 error.
>
> Followign are the entries in struts-config.xml file
>
> <action
> path="/TestAction"
> type="devika.TestAction">
> <forward name="testAction" path="/TestAction.jsp"/>
> </action>
>
> following is entry in .jsp file
>
> <html:link page="/TestAction.do">Test the Action</html:link>
>
> Kindly please help me
>
> D


 
Reply With Quote
 
in_dv
Guest
Posts: n/a
 
      11-08-2006
Thx for the reply. Do I need to keep the same case for forward and
struts config?

(E-Mail Removed) wrote:
> Your case is different in the forward and Struts Config.
>
>
> in_dv wrote:
> > Hello All,
> >
> > I am a newbie to struts. I am trying to get a simple example working
> > which I found on jakarta struts tutorial.
> >
> > When I click on a link, I expect it to transfer to TestAction.jsp page
> > , but I can see it changes to TestAction.do and I get "Page Cannot be
> > found" HTTP 404 error.
> >
> > Followign are the entries in struts-config.xml file
> >
> > <action
> > path="/TestAction"
> > type="devika.TestAction">
> > <forward name="testAction" path="/TestAction.jsp"/>
> > </action>
> >
> > following is entry in .jsp file
> >
> > <html:link page="/TestAction.do">Test the Action</html:link>
> >
> > Kindly please help me
> >
> > D


 
Reply With Quote
 
in_dv
Guest
Posts: n/a
 
      11-08-2006
Thank you very much for your reply.
I am pasting the code for TestAction.java file below

/////////////////////////

package devika;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class TestAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
return mapping.findForward("testAction");
}
}

//////////////////////////////////

Then why m i getting page cannot be diplayed error ?
Tim Slattery wrote:
> "in_dv" <(E-Mail Removed)> wrote:
>
> >Hello All,
> >
> >I am a newbie to struts. I am trying to get a simple example working
> >which I found on jakarta struts tutorial.
> >
> >When I click on a link, I expect it to transfer to TestAction.jsp page
> >, but I can see it changes to TestAction.do and I get "Page Cannot be
> >found" HTTP 404 error.
> >
> >Followign are the entries in struts-config.xml file
> >
> ><action
> > path="/TestAction"
> > type="devika.TestAction">
> > <forward name="testAction" path="/TestAction.jsp"/>
> > </action>
> >
> >following is entry in .jsp file
> >
> ><html:link page="/TestAction.do">Test the Action</html:link>

>
> That link causes the Struts front end to search the struts-config.xml
> file and find the "action" you've reproduced above. That "action"
> element tells it to transfer control to "devika.TestAction.class".
> Presumably that class will eventually pass control to the
> TestAction.jsp page (by coding something like:
>
> mapping.findForward("testAction");
>
> --
> Tim Slattery
> (E-Mail Removed)


 
Reply With Quote
 
Tim Slattery
Guest
Posts: n/a
 
      11-08-2006
"in_dv" <(E-Mail Removed)> wrote:

>Thx for the reply. Do I need to keep the same case for forward and
>struts config?


No, they're talking about different things. The "path" attribute of
"action" gives a name that will be matched to the URL sent to the app.
The "path" attribute of the "forward" tag points to a JSP page.

--
Tim Slattery
(E-Mail Removed)
 
Reply With Quote
 
in_dv
Guest
Posts: n/a
 
      11-09-2006
So is my information right? I am stll not able to get this work

Tim Slattery wrote:
> "in_dv" <(E-Mail Removed)> wrote:
>
> >Thx for the reply. Do I need to keep the same case for forward and
> >struts config?

>
> No, they're talking about different things. The "path" attribute of
> "action" gives a name that will be matched to the URL sent to the app.
> The "path" attribute of the "forward" tag points to a JSP page.
>
> --
> Tim Slattery
> (E-Mail Removed)


 
Reply With Quote
 
impaler
Guest
Posts: n/a
 
      11-09-2006


On Nov 9, 4:26 pm, "in_dv" <(E-Mail Removed)> wrote:
> So is my information right? I am stll not able to get this work
>


Do you have everything set up?

web.xml should have
<!--=============================-->
<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>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>application</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!--=============================-->

to load the action servlet and map the *.do (I've noticed that you use
this) url pattern to the action servlet.

And also check struts.jar to be in the WEB-INF/lib or in the server's
common lib folder (with all the dependencies)

 
Reply With Quote
 
in_dv
Guest
Posts: n/a
 
      11-09-2006
Thx for the reply. I have the same entries in my web.xml file and this
is the output of ls command at WEB-INF/lib directory
[root@pw-psni-01 lib]# ls
activation.jar commons-dbcp-1.2.1.jar commons-lang-2.0.jar
commons-pool.jar pg74.214.jdbc3.jar tax.jar
commons-beanutils.jar commons-digester.jar commons-logging.jar
commons-validator.jar servlet.jar
commons-collections.jar commons-fileupload.jar commons-pool-1.2.jar
keep.me struts.jar

..Kidly let me know what else I should check
impaler wrote:
> On Nov 9, 4:26 pm, "in_dv" <(E-Mail Removed)> wrote:
> > So is my information right? I am stll not able to get this work
> >

>
> Do you have everything set up?
>
> web.xml should have
> <!--=============================-->
> <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>debug</param-name>
> <param-value>2</param-value>
> </init-param>
> <init-param>
> <param-name>detail</param-name>
> <param-value>2</param-value>
> </init-param>
> <init-param>
> <param-name>application</param-name>
> <param-value>application</param-value>
> </init-param>
> <load-on-startup>2</load-on-startup>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>action</servlet-name>
> <url-pattern>*.do</url-pattern>
> </servlet-mapping>
> <!--=============================-->
>
> to load the action servlet and map the *.do (I've noticed that you use
> this) url pattern to the action servlet.
>
> And also check struts.jar to be in the WEB-INF/lib or in the server's
> common lib folder (with all the dependencies)


 
Reply With Quote
 
in_dv
Guest
Posts: n/a
 
      11-10-2006
Hi all,

I checked the apache logs and found the error that

<APP-ROOT>/TestAction.do file does not exist. Its probably
misunderstanding it as link rather than action.Its trying to look for
the file TestAction.do rather than finding the action mappings for *.do
.. What configuration m I missing for this behaviour? I truly appreciate
your help

Thanks

in_dv wrote:
> Thank you very much for your reply.
> I am pasting the code for TestAction.java file below
>
> /////////////////////////
>
> package devika;
>
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
>
> import org.apache.struts.action.Action;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionForward;
> import org.apache.struts.action.ActionMapping;
>
> public class TestAction extends Action
> {
> public ActionForward execute(
> ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response) throws Exception{
> return mapping.findForward("testAction");
> }
> }
>
> //////////////////////////////////
>
> Then why m i getting page cannot be diplayed error ?
> Tim Slattery wrote:
> > "in_dv" <(E-Mail Removed)> wrote:
> >
> > >Hello All,
> > >
> > >I am a newbie to struts. I am trying to get a simple example working
> > >which I found on jakarta struts tutorial.
> > >
> > >When I click on a link, I expect it to transfer to TestAction.jsp page
> > >, but I can see it changes to TestAction.do and I get "Page Cannot be
> > >found" HTTP 404 error.
> > >
> > >Followign are the entries in struts-config.xml file
> > >
> > ><action
> > > path="/TestAction"
> > > type="devika.TestAction">
> > > <forward name="testAction" path="/TestAction.jsp"/>
> > > </action>
> > >
> > >following is entry in .jsp file
> > >
> > ><html:link page="/TestAction.do">Test the Action</html:link>

> >
> > That link causes the Struts front end to search the struts-config.xml
> > file and find the "action" you've reproduced above. That "action"
> > element tells it to transfer control to "devika.TestAction.class".
> > Presumably that class will eventually pass control to the
> > TestAction.jsp page (by coding something like:
> >
> > mapping.findForward("testAction");
> >
> > --
> > Tim Slattery
> > (E-Mail Removed)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it safe to point to Internet for locating struts DTD files in struts TLDs and XML files? Katie Wright Java 8 01-07-2005 03:37 PM
[Struts] Newbie - For ActionForm population, must I use Struts taglib? Pratap Das Java 2 04-05-2004 07:42 PM
[Struts]output javascript in struts perform() sin Java 3 02-22-2004 08:27 AM
Integrate a Struts app with a non-struts app jc1771 Java 0 12-28-2003 06:36 PM
Struts Installation - missing struts.tld??? Jason Us Java 0 10-03-2003 11:36 PM



Advertisments