• 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

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

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 75
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
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
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
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cheers J. Kevin Robbins - JSP version 1.2
 
Bear Bibeault
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
Yikes, man. That's like running Windows 3.1. Why are you running such an old version of servlets/JSP?
 
Declan Barrett
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 )
 
reply
    Bookmark Topic Watch Topic
  • New Topic