wood burning stoves*
The moose likes Struts and the fly likes How to enter action class without using action form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to enter action class without using action form" Watch "How to enter action class without using action form" New topic
Author

How to enter action class without using action form

satya pradh
Greenhorn

Joined: May 29, 2009
Posts: 2
Hi

i am new to struts application . in my applicaton i got an error regading form bean returns null (Exception) while executing it. Actually what i did i enter user id & password in to login page it works fine & got the result .now i add one button named logout ,i got the problem here ,i wnt to login. i gave the userid & password i got the error .what i did in my application i used </html:fom> wher it call anothe action class

my jsp code
<html:submit value="login">Login</html:submit>
<html:submit>Logout</html:submit>
<html:form action="/Logout" method="post">

Strutsconfig.xml
<form-beans>
<form-bean name="LoginForm" type="com.app.orbit.Form.LoginForm"/>

</form-beans>
<action-mappings>
<action path="/Login"
type="com.app.orbit.Action.LoginAction"
name="LoginForm"
scope="request"
validate="true"
input="/pages/login.jsp">
<forward name="success" path="/pages/loginsuccess.jsp"/>
<forward name="fail" path="/pages/Loginfail.jsp"/>
</action>
<action path="/Logout"
name="LoginForm"
scope="request"
input="/pages/login.jsp"
type="com.app.orbit.Action.LogoutAction">
<forward name="success" path="/pages/login.jsp"/>

</action>
<action path="/Welcome" forward="/pages/login.jsp"/>
</action-mappings>

please help how i can enter to anothe action class

Thanks in advance
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Hi Satya, welcome to javaranch.

When you use html:form tag, the target action class must have a form bean defined for it. I suppose you can skip this by using a normal form tag instead of html:form tag...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Or just use a link.
satya pradh
Greenhorn

Joined: May 29, 2009
Posts: 2
Ankit ,yes you are right


i did not write form bean.so can you please tell me if i use general from to call action, i tried that one also but when i clicked on button no event hasnotbeen occured . can you plese guide me regarding this
<input type="submit" name="submit" value="logout" onclick=logout()>
function logout(){
<form action=/login.do>
}

Thanks in advance
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags.

Am I understanding what you've written here correctly?Is that a form tag inside a JavaScript function?
 
wood burning stoves
 
subject: How to enter action class without using action form