• 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 Page redirection

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

I like to know how to populate the listbox dynamically using jsp..

The scenario is i have two list box in my jsp page form where the selection of value from list 1 should populate the list 2.

How can i do it through servlet,jsp so that i retain the previous values entered in my form and also get the list 2 populated based on the value selection in list1.

My problem is how do i redirect/forward (since i use post method - i can change it to get if required) to the appropriate page (I used javascript onchange event) and how i retain the previous entered in the form when i come back to it.

Any inputs /ideas is greatly welcome.. thanx for the time in advance.

Regards
Roshini.S
 
Roshini Sridharan
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anybody there , who can give some ideas.

I try to forward the request on my script onchange event, but this stops loading the whole page itself..

I am populating the listbox using JSTL for:each.

Any inputs is highly appreciated.

Thanx in advance.

Regards
Roshini.S
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an example app that does this.
It's not done with pure JSP (model1).
It uses MVC, but the concept is the same.

http://simple.souther.us/not-so-simple.html
Look for Dynamic Select Lists.
 
Roshini Sridharan
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Mr.Ben,

Thanx a lot. I went thru the application and it works great.

I have some more clarification..

The form is a jsp that has other additional fields so this selection comes as 6th field which mean the user has filled out the previous 5 fields in the form.

I use Javascript onchange event that directs to a servlet that chooses the relevant values for 2nd list box and forwards back to the JSP.

Here i try to bring back the previous 5 + 1 value entered and selected by the user.

I have done that, since i used JSTL for substituting values in the JSP i find lot of whitespace substituted in the html anyway is there to avoid it.

I am using Tomcat 5.0. Thanx for the time.

Regards
Roshini.S
[ July 20, 2006: Message edited by: roshini sridhar ]
 
Sheriff
Posts: 67746
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 roshini sridhar:
i find lot of whitespace substituted in the html anyway is there to avoid it.



That's pretty much the nature of JSP. This article goes into details regarding the preserving of whitespace.

Except for very large pages, a little whitespace isn't a big deal, but if you are concerned about network overhead, you could write a servlet filter to remove excess whitesapce or to gzip the output.
[ July 20, 2006: Message edited by: Bear Bibeault ]
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic