• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

A few questions regarding dropdown lists in JSP

 
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 All,

[I have edited my initial question to this shorter one]

Basically, whats the best way to retain form data between multiple JSPs without using a submit button?

Essentially, when a user selects a value from a drop down list on one of the JSPs which populated multiple entries within a form, I want this selected data to be 'retained' between different JSPs until such time the user is happy with what they have selected. At which point the user can opt to 'submit' their selections from one of the JSPs - this is the only page to contain a submit button.

Is JavaBeans the way to go? I recently read that using JavaBeans with Servlets doesnt really conform to the correct standard. Ideally, if someone could advise if this is possible by only using JSTL along with session scope variables then that would be appreciated.

Hopefully my questions make sense however if not then please dont hesitate to let me know

Thanks in Advance

John Paul
 
John Paul Hoey
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 All,

I 'think' I have figured out my question therefore I am marking this as resolved.

Cheers
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi John. So what did you do to solve your problem?

From your initial post, storing such in session scope is one way, Java bean could be another.
 
John Paul Hoey
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 K. Tsang,

I decided to go with session scope however can I ask what is the preferred way to store data between JSP and Servlets? Is it to use JavaBeans or to use Session scope? Is there a benefit to one over the other? Or is it subjective?

Thanks in advance
 
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

John Paul Hoey wrote:I recently read that using JavaBeans with Servlets doesnt really conform to the correct standard.


Hogwash. Beans are used extensively in web apps, especially in communicating between the servlet controllers and JSPs.

Ideally, if someone could advise if this is possible by only using JSTL along with session scope variables then that would be appreciated.


Not sure what you mean by "only". Web technologies are used in concert.
 
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

John Paul Hoey wrote:I decided to go with session scope however can I ask what is the preferred way to store data between JSP and Servlets?


It depends. Session scope should only be used for longer-term storage. Communications between a page controller and its JSP usually employs request scope. Your reliance on session scope may be an indication of a fundamental design problem.

Is it to use JavaBeans or to use Session scope? Is there a benefit to one over the other?


"or"? It's not an either or. You can store any objects you want in the various scopes. Whether the objects are beans or not is irrelevant. In fact, most of the time, they will be.

Your question is like asking "Which should I use: an egg crate, or eggs?" The session scope (and other scopes) are containers, beans are just one of the things you can put into the containers.

I'm getting a feeling that there's a fundamental misunderstanding going on here, but I don't have enough info to pin it down. Statements like the above are a clear red flag though.
 
John Paul Hoey
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 Bear,

Thanks for your response.

Hogwash. Beans are used extensively in web apps, especially in communicating between the servlet controllers and JSPs.



Yeah I was getting confused here. What I was actually meaning was in relation to the statement:

Do NOT use <jsp:useBean> if you're already using a servlet to process the model. It will only lead to confusion and maintenance trouble because the <jsp:useBean> follows a different level of MVC approach than when you're using servlets. It's either servlets or <jsp:useBean>, not both



Which it states at the bottom of the following link:

Stack Overflow - Servlets

This now makes sense to me.

Thanks again.
 
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
Right. The useBean tag has very limited use in the past 13 years after the introduction of the JSTL and EL. In general, it's superfluous and should not be used.

But that has nothing to do with the use of beans themselves; just with the use of that tag (and its brethren such as getProperty and setProperty).
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic