aspose file tools*
The moose likes Struts and the fly likes neither action class called nor jsp page displayed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "neither action class called nor jsp page displayed" Watch "neither action class called nor jsp page displayed" New topic
Author

neither action class called nor jsp page displayed

vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
I have developed a very basic struts application. but my action class in not getting called. Please check below the web.xml, struts-config.xml files, and LoginAction.java files:

web.xml



struts-config.xml



LoginAction.java



Please let me know, whats the problem in above code. if you require, i will copy LoginForm.java and welcome.jsp files also.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Is the application starting up? Is there anything in the log files?
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
David,

nothing is entered in the log file. log file not even displaying the s.o.p statement written in the LoginAction class. it seems class is not getting loaded properly. i am using tomcat 4.1 server and my folder structure is as follows:

LoginTest\jsp\welcome.jsp
LoginTest\WEB-INF\web.xml
LoginTest\WEB-INF\struts-config.xml
LoginTest\WEB-INF\src\com\LoginAction.java
LoginTest\WEB-INF\src\com\LoginForm.java
LoginTest\WEB-INF\classes\com\LoginAction.class
LoginTest\WEB-INF\classes\com\LoginForm.class
LoginTest\WEB-INF\lib\struts.jar

is there any problem with the folder structure?

please correct me if i am wrong. i guess LoginAction.class and LoginForm.class should be directly under classes\ directory instead of classes\com\ directory.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You didn't include the "package" statement in your posted Java code, so I have no way of knowing where they belong. What package are they in?

Does Struts really have no dependencies other than the struts jar file? I'm pretty skeptical of that. I don't know what version of Struts you're using, but even S1.2.9 has a number of other dependencies like commons-digester and so on. Right now I'm still thinking your application isn't even starting up. I'm also surprised there's nothing in the log file or the console, because it'll definitely show error messages if the app doesn't start up.
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
David,

here are few more inputs:

-- the package name is com.

-- i am using 1.4 version of Struts

-- my application is starting up properly but not showing any output.

-- yes, there's nothing in the log file or the console.

thanks.
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
now, i put non-arg constructors in the LoginAction and LoginForm classes. Then I invoke the url again, this time s.o.p. written in the constructor of LoginAction class and LoginForm classes are displayed in the log file but execute method s.o.p. statement is not displayed.

can anyone explain me, where am getting wrong.
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
i have not written reset or validate method in the LoginForm class. is it ok? and also, i have not entered input tag for action class in the struts-config.xml file. is it ok?

as per my knowledge, these are optional, but am asking this after reading below lines from the webpage :

execute() method of an action class is not called if ActionForm.validate() returns non-empty ActionErrors object. Instead, control is directly routed to the URI defined in "input" attribute of action mapping.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

vikas sharmaa wrote:i have not written reset or validate method in the LoginForm class. is it ok? and also, i have not entered input tag for action class in the struts-config.xml file. is it ok?


as per my knowledge, these are optional, but am asking this after reading below lines from the webpage :

execute() method of an action class is not called if ActionForm.validate() returns non-empty ActionErrors object. Instead, control is directly routed to the URI defined in "input" attribute of action mapping.


Its not mandatory to write this two methods.. input tag, is for If any validations error that should be returned to input tag JSP page..

And change the <load-on-startup> tag value to 1. Its just a guess.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
sagar,

it does not work even after changing the value of <load-on-startup> tag to 1.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

vikas sharmaa wrote:I have developed a very basic struts application. but my action class in not getting called. Please check below the web.xml, struts-config.xml files, and LoginAction.java files:




Please let me know, whats the problem in above code. if you require, i will copy LoginForm.java and welcome.jsp files also.


execute() method throws Exception not IOException, ServletException, since Struts 1.0.
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
sagar,

i changed throws clause to Exception, still no results.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You're using 1.4? Have you successfully written an application using an actual released version? How are you building it?
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
many thanks david and sagar for your support. the problem is fixed now! i was mistakenly using older version of struts.jar where execute method was not defined in the Action class. i learned a lot many basic things by this mistake.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

vikas sharmaa wrote:the problem is fixed now! i was mistakenly using older version of struts.jar where execute method was not defined in the Action class.


Ohh man, You forced to conclude a new BIG bug in Struts1.x..

Actually , prior to Struts 1.x , there is Action#perform() method later it is replaced with Action#execute() method..

So version is what one should looked for.. hmm
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: neither action class called nor jsp page displayed