473,487 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

action class is not executing in struts

58 New Member
hi all,
i got a problem with struts.
iam unable to find it.
i have written an action class, form bean class and a jsp page
on submitting form, request is going to action class but it is not executing action class iam unable to solve it...
here is my code
FormLogin.java
[code]
public class FormLogin extends ActionForm{
private String username=null;;
private String password=null;;

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.username=null;
this.password=null;


}
}
[/CODE}
ActionLogin.java
Expand|Select|Wrap|Line Numbers
  1. public class ActionLogin extends Action {
  2. public ActionForward execute(HttpServletRequest req, HttpServletResponse res,
  3.         ActionForm form, ActionMapping mapping)throws Exception
  4. {
  5.     System.out.println("this is action class");
  6.     FormLogin fl=(FormLogin)form;
  7.     System.out.println(fl.getUsername());
  8.     System.out.println(fl.getPassword());
  9.     return mapping.findForward("success");
  10.     }
  11. }
  12.  
  13.  
login.jsp
Expand|Select|Wrap|Line Numbers
  1. <html:form action="/login">
  2. <html:text property="username">username</html:text>
  3. <html:password property="password">password</html:password>
  4. <html:submit>submit</html:submit>
  5. </html:form>
  6.  
struts-cfg.xml
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
  3. <struts-config>
  4.  
  5.    <form-beans>
  6.    <form-bean
  7. name="FormLogin"
  8. type="com.yourcompany.struts.FormLogin"/>
  9.  
  10.  
  11. </form-beans>
  12.  
  13.    <global-exceptions />
  14.  
  15.    <action-mappings>
  16.    <action
  17.      path="/login"
  18.      type="com.yourcompany.struts.ActionLogin"
  19.      name="FormLogin"
  20.      scope="request"
  21.      validate="true"
  22.      input="/Pages/login.jsp">
  23.       <forward name="success" path="/Pages/Success.jsp"/>
  24. </action>
  25. </action-mappings>
  26.    <message-resources parameter="com.yourcompany.struts.AppllicationResources" />
  27. </struts-config>
  28.  
  29.  
Success.jsp page has
Expand|Select|Wrap|Line Numbers
  1. <body>
  2. success fully login
  3. </body>
  4.  
login.jsp and Success.jsp pages are in pages folder of webroot.
when i send request to login.jsp form was displayed but when i will submit the form it is not going to success.jsp blank page is coming..
the request will be like this when i submit form
http://localhost:8080/StrutsApp/login.do
how can i solve it...
May 31 '07 #1
3 5385
sumittyagi
202 Recognized Expert New Member
I don't know much about struts, but I think your problem lies here:
Expand|Select|Wrap|Line Numbers
  1. <html:password property="password">password</html:password>
  2.  
It would be a javascript problem. don't give reserved words names to your variables.
I think the above statement will be generating the equivalient in html:
Expand|Select|Wrap|Line Numbers
  1. <input type="password" name="password" />
  2.  
.

rename it to pwd or password1 or userPassword etc.
Expand|Select|Wrap|Line Numbers
  1. <html:password property="userPassword">password</html:password>
  2.  
May 31 '07 #2
pavancognizant
7 New Member
whats the mapping of action in your web.xml if its *.do then put login.do in your action attribute of html form tag..... and also see if there is any exception in your server console....

<html:form action="login.do">


I don't know much about struts, but I think your problem lies here:
Expand|Select|Wrap|Line Numbers
  1. <html:password property="password">password</html:password>
  2.  
It would be a javascript problem. don't give reserved words names to your variables.
I think the above statement will be generating the equivalient in html:
Expand|Select|Wrap|Line Numbers
  1. <input type="password" name="password" />
  2.  
.

rename it to pwd or password1 or userPassword etc.
Expand|Select|Wrap|Line Numbers
  1. <html:password property="userPassword">password</html:password>
  2.  
May 31 '07 #3
shanmukhi
58 New Member
I don't know much about struts, but I think your problem lies here:
Expand|Select|Wrap|Line Numbers
  1. <html:password property="password">password</html:password>
  2.  
It would be a javascript problem. don't give reserved words names to your variables.
I think the above statement will be generating the equivalient in html:
Expand|Select|Wrap|Line Numbers
  1. <input type="password" name="password" />
  2.  
.

rename it to pwd or password1 or userPassword etc.
Expand|Select|Wrap|Line Numbers
  1. <html:password property="userPassword">password</html:password>
  2.  

Thank u for your reply

but that is not the problem with my code..
i solved it.
the problem is with parameters of execute method in action class
i changed the sequence of parameters in the execute method..

The sequence should be
Expand|Select|Wrap|Line Numbers
  1. execute(
  2.     ActionMapping mapping,    ActionForm form, HttpServletRequest request, 
  3.         HttpServletResponse response)
  4.  
Jun 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3032
by: James | last post by:
Running on Xp with WSAD5.0.1 (acts the same in 5.1) an action class is simply not being called when it is configured identically with others called in the same manner. It never gets into the...
1
2860
by: gilgantic | last post by:
Few random questions about Struts: (Note: I left out ActionServlet and Model classes out of my questions) 1. Should every JSP have one "ActionForm" and "Action" class associated with it? 2. Is...
1
11867
by: Cedric | last post by:
Hello, I'm developping my first Struts application. I've got this error: Cannot find message resources under key org.apache.struts.action.MESSAGE web.xml <servlet>...
5
9112
by: Jeppe | last post by:
Hi @ll, I'm investigating the possibility to call a struts action on a web environment from a standalone java application. I need to make this call automatically, from a crontab (on unix)....
3
10257
by: sancha | last post by:
Hi, i am in a bit of a delima here. I need to submit an action through javascript so i used document.forms.action='/search.do?&submitaction=Add Minus' document.forms.submit(); since i am...
0
3260
by: sachindanayak | last post by:
Hi, Could I get a help how to call a struts action to an IFRAME. It should something similar to FRAME tag forward="strutsaction". By trying similar for IFRAME I am getting Not found error. ...
1
2084
kaleeswaran
by: kaleeswaran | last post by:
HI! i am working in banking domain.. now i struggled with that displaying more number of rows in data..i have a screen like passing type like if the manager wants to passing the loan sanction...
0
1668
by: prisesh26 | last post by:
hi, i am using struts in my project. all my errors are shows through action errors. now iam having a scenario where i need to display Errors from my action. so using addError. but i need to...
1
1649
by: sri9rams | last post by:
can anyone give me some idea how to call a url or struts action class from a stand alone java program.it wud be helpful if there is a sample code
0
7137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.