wood burning stoves 2.0*
The moose likes Struts and the fly likes LogOut Action is not Working, when I do validations in Action or in XML file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "LogOut Action is not Working, when I do validations in Action or in XML file." Watch "LogOut Action is not Working, when I do validations in Action or in XML file." New topic
Author

LogOut Action is not Working, when I do validations in Action or in XML file.

Ramakrishna Udupa
Ranch Hand

Joined: Aug 09, 2013
Posts: 253
Hi All,

Here is my source code

Web.xml:



Struts.xml



ActionClass.java



ActionClass-validation.xml


Model.java which has two variables Username and password with getters and setters.

Business service, comparing hard coded value username as username and password as password.

index.jsp


result.jsp



more.jsp


Problem is, exception is happening when I click logout button. logout method is not executing.

Exception is:

" HTTP Status 404 - No result defined for action com.rk.java.Action.ActionClass and result input ".

I got that I've to give <result name="input">/index/other.jsp</result>. But no need of this line, when I'm doing logout. I think struts-2 Again doing validation i.e ActionClass-validation.xml. Can anybody tell the solution please.

Thanks:
Ramakrishna K.C


[Capture.PNG]

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8877
    
    8

Ramakrishna Udupa wrote:
I got that I've to give <result name="input">/index/other.jsp</result>. But no need of this line, when I'm doing logout. I think struts-2 Again doing validation i.e ActionClass-validation.xml. Can anybody tell the solution please.


The way you have your application set up, this behavior is correct. If you look at the validation documentation:

Validation rules can be specified:
Per Action class: in a file named ActionName-validation.xml
Per Action alias: in a file named ActionName-alias-validation.xml


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Ramakrishna Udupa
Ranch Hand

Joined: Aug 09, 2013
Posts: 253
Thanks for the reply Joe Ess,

That Means I've to validate only the method execute() not all methods in ActionClass. That's what you are telling me right? Can you elaborate your explanation please? And I dint get the solution. No idea what to do.


Thanks:
Ramakrishna K.C
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8877
    
    8

Basically you get the first thing:
Per Action class: in a file named ActionName-validation.xml


What you want to do is the second thing:
Per Action alias: in a file named ActionName-alias-validation.xml

that limits the validation to a particular action.
Ramakrishna Udupa
Ranch Hand

Joined: Aug 09, 2013
Posts: 253
Hi Joe Ess,

I got that. But It is not doing empty check-validation. I renamed that ActionClass-Validation.xml to ActionClass-login-validation.xml. It is now logging out perfectly. But Basic validation i.e empty check validation is not happening.

Also interceptor is not working. If I directly take the URL and paste that into another browser, It is not validating instead it is showing null pointer exception.

My Interceptor class:


It returns input if session is not there. But, Instead of showing index.jsp it is taking that URL and showing NullPointer-Exception.

Thanks:
Ramakrishna K.C
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8877
    
    8

Ramakrishna Udupa wrote:Hi Joe Ess,

I got that. But It is not doing empty check-validation. I renamed that ActionClass-Validation.xml to ActionClass-login-validation.xml. It is now logging out perfectly. But Basic validation i.e empty check validation is not happening.



Do you have an action named "login" in your struts.xml? I don't see it.

Ramakrishna Udupa wrote:
Also interceptor is not working. If I directly take the URL and paste that into another browser, It is not validating instead it is showing null pointer exception.


I'm not sure what you are trying to accomplish with your interceptor. You should read the Writing Interceptors guide in the Struts docs. Carefully. It would also be good to tell us which line the exception is happening on or share the stack trace.
Ramakrishna Udupa
Ranch Hand

Joined: Aug 09, 2013
Posts: 253
Hi Joe Ess,

I renamed execute() method to login() method.

I think, Interceptor is correctly done. There's no mistake in Interceptor.

Thanks:
Ramakrishna K.C
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LogOut Action is not Working, when I do validations in Action or in XML file.