aspose file tools*
The moose likes Struts and the fly likes How to find method in Sturts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to find method in Sturts" Watch "How to find method in Sturts" New topic
Author

How to find method in Sturts

Pradeeep Sharma
Ranch Hand

Joined: Dec 04, 2008
Posts: 32
HI,
Can any one tell me how to find that if the method is of type 'post' or not.
I want to know this because i made a simple login page in sturts . It's working fine but the problem is that when i submits the form it stores the old values in the textfields , even when i restart tomcat and runs application very first time it was still displaying the old value in the fields.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Pradeeep Sharma wrote:HI,
Can any one tell me how to find that if the method is of type 'post' or not.

HttpServletRequest#getMethod()
Pradeeep Sharma wrote:
I want to know this because i made a simple login page in sturts . It's working fine but the problem is that when i submits the form it stores the old values in the textfields , even when i restart tomcat and runs application very first time it was still displaying the old value in the fields.



That's a weird problem, If you restart the tomcat all the values, whatever may be the scope, will destroy..

Had you hard coded the login values in your JSP code ? Please post your Login.jsp and Login action class.


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

Joined: Dec 04, 2008
Posts: 32
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Where you faced the problem, in login page or in registration page.. Also some doubts,

the XDoclet shows, action path as :



But in register.jsp the action path is:


Pradeeep Sharma
Ranch Hand

Joined: Dec 04, 2008
Posts: 32
I am facing problem in both forms . Below i am pasting the struts-config.xml for register page...


Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Code looks fine or may be I'm missing something.. Still, just want some modification ,

Defining instance variables for action class is considered as bad practice, they might store the variables values for the next request fot the same action class. To know more about, search Struts action class instance variables
So make them local,




try this.
Pradeeep Sharma
Ranch Hand

Joined: Dec 04, 2008
Posts: 32
Hi,
Yup this is working now, by making instance variables local. Thanks for the help.
But i have confusion now that , the action class is called only when i submit the form, that means the action class's variables(weather they are instance or local) should be defined and initialized only when the class is called, then why the Form was showing the old values even when the page was opened for the first time.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Pradeeep Sharma wrote:Hi,
Yup this is working now, by making instance variables local. Thanks for the help.

You're welcome
Pradeeep Sharma wrote:
But i have confusion now that , the action class is called only when i submit the form, that means the action class's variables(weather they are instance or local) should be defined and initialized only when the class is called,


Yes, you are right, for the very first request, Servlet container (server) creates and initialized the instance variables, and for the any sub sequent request for the same action, server uses thread of that class to serve. And I told you, you can have many resources to discussed this on web.

Pradeeep Sharma wrote:
then why the Form was showing the old values even when the page was opened for the first time.

That's where I'm confused, coz you said I restarted the server, and still you have those previous sessioned values, are you serializing/persisting this values some where else Its magic
Pradeeep Sharma
Ranch Hand

Joined: Dec 04, 2008
Posts: 32
No, i was not doing anything else the code i posted.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find method in Sturts