This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Page redirection

 
Roshini Sridharan
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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 ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic