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

neither action class called nor jsp page displayed

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the application starting up? Is there anything in the log files?
 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sagar,

it does not work even after changing the value of <load-on-startup> tag to 1.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sagar,

i changed throws clause to Exception, still no results.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic