File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSTL String in Loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL String in Loop" Watch "JSTL String in Loop" New topic
Author

JSTL String in Loop

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1394
I would like to create a string in the JSTL loop by concatenating a "0" with the varStatus property. However the following seems to drop the "0".

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

What the heck is faiInspectionLocationLogHoldLocationOption? and why would it have a leading zero?

The appropriate approach would be to fix the data rather than jumping through hoops in the JSP.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1394
Bear Bibeault wrote:What the heck is faiInspectionLocationLogHoldLocationOption? and why would it have a leading zero?

The appropriate approach would be to fix the data rather than jumping through hoops in the JSP.


Remember you asked:

My record location options from datatable are:
1 CMM Room
2 Tooling Inspection

I am providing a form that the user can fill out using barcodes.

Well, guess what? Single digit barcodes will not scan so the option is to make it 01, 02.

Now the user can choose an option to repeat the previous entries. The input for the location option is a drop down list. So the faiInspectionLocationLogHoldLocationOption is a stored session attribute that needs to match the foreach loop varStatus so it knows what should be auto selected.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
My solution if you are going for a minimal fix




Other leading questions
Why is "faiInspectionLocationLogHoldLocationOption" a number formatted in this way?
As opposed to something like the VALUE that should be selected from the dropdown?

Rather than writing out a select tag and options, conditionally marking one as selected (ie doing it manually) my preference is to use a framework which provides JSP tags to accomplish the task
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSTL String in Loop
 
Similar Threads
JSTL - total count for loop within a loop
How to prevent DIV from reloading
Color Table Rows Based on a Field Value
Coloring Table Rows
Detecting a Null Array Element in JSTL