• 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

How to find method in Sturts

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

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.
 
Pradeeep Sharma
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
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
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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am facing problem in both forms . Below i am pasting the struts-config.xml for register page...


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

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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, i was not doing anything else the code i posted.
 
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic