Help coderanch get a
new server
by contributing to the fundraiser
  • 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

JSP + useBeans + flush all my contents in my page

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i have been searching the internet but I cannot find anything clue to this issue.Appreciate if anyone can help me with this.

Currently I have a form in my JSP. This form when submitted should return back to this JSP again.


I have beans to capture the fields for a particular form
<jsp:useBean id="formHandler" scope="page" class="ed21.nday.bean.CapturingNomParticularsBean">
<jsp:setProperty name="formHandler" property="*"/></jsp:useBean>

However if I submit this form and return back to this JSP, the rest of the contents (outside this form) will be rewritten and will query my database again. How can I just retain the information in the JSP?

I can paste my codes if you do not understand what I say.

Thanks
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is why the pattern that you are using is no longer considered apprpriate. By mixing your processing with the generation of the page, you have no ability to separate them.

You would be better served to study modern accepted practices with regards to web application structure. Perhaps this article might be a good starting point.
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

thanks for your reply.

However i think you might have misunderstand my questions.


I use a bean in my jsp and when I click submit, all the get and set methods in the bean will be invoked. How can I just specify which set methods to invoke?

I cannot use a variable/flag as once I click the submit button and return to this same page, all the variables are reset and all set methods are invoked as well. One of my set method is calling the database. I do not want this method to be called again since it has been called once. I want it to call once when the JSP is shown by a user.
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps I should use JSF? To retain information?
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ken Flor:

However i think you might have misunderstand my questions.



No, I'm very familiar with your issue. And I have the scars to prove it. Did you read the article?

You issue is due to poor application structure caused by ganging up all your processing and view generation together into a JSP.

What makes you think JSF would help?
 
Hey! Wanna see my flashlight? It looks like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic