Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Trying to set <option> values dynamically on JSP with for loop  RSS feed

 
Declan Barrett
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi,

Apologies if this is not the right forum for this question.

I'm trying to create a set of values in a dropdown list dynamically as follows:


This will create a list of values starting at 2013 and ending with 2001 and this is exactly what we want.

The problem, however, is that when the page is submitted it returns and defaults the first value back into the box i.e. 2013. Is there any way to default in the value that the user selected or should I not use a for loop to create the list?

By the way, I know absolutely nothing about jQuery, JSON etc and have a beginner's knowledge of java and JSPs

All help greatly appreciated.
 
Claudiu Chelemen
Ranch Hand
Posts: 75
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think in terms of basic HTML. How can you make a simple option tag automatically get selected on page load ?
Also, consider from moving away from scriptlets and using JSTL and EL.

Claudiu
 
Declan Barrett
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it....the answer is to enclose the value being assigned to the option value in single quotations '' and, in my particular case, use a specific check as follows:



Cheers Claudiu for prompting me to take a step back
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take the other advice you were given to heart: using Java code in a JSP is a bad practice from over 13 years ago! You should be using the JSTL and EL!
 
Declan Barrett
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take the other advice you were given to heart: using Java code in a JSP is a bad practice from over 13 years ago! You should be using the JSTL and EL!


That is definitely the intention but currently time constraints dictate otherwise unfortunately
 
Declan Barrett
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I find out if the version of JSP that I'm working with can handle EL and JSTL etc?
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out this thread for determining your version.

You need at least JSP 2.0 for EL and JSTL support.
 
Declan Barrett
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers J. Kevin Robbins - JSP version 1.2
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yikes, man. That's like running Windows 3.1. Why are you running such an old version of servlets/JSP?
 
Declan Barrett
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The product we have is known as Biller direct and that's the version that was delivered as far as I know....Hopefully we'll upgrade it in the not-too-distant future but for now we're trying to customise it a bit before go-live...steep learning curve but enjoyable (when it works )
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!