I am currently using a javaBean to save/load values to and from a jsp. Here what is happening:
I have the following line in my jsp:
<td><input class="partDescription" name="partDescription" style="width: 250px" type="text" readonly="readonly" value=<%=affectedBean.getPartDescription().get(i) %> /></td>
When I debug through the code this is value stored in the affectedBean.getPartDescription at index 0: BK SLOPE CONTROLLER
However, when it the page finishes loading the only thing it shows is in that location is: BK
Other examples:
Value: ROLF REDESIGNED UL SUPPLY; Displays: ROLF
Value: 18 FUEL SENSOR; Displays: 18
Anybody have any ideas
In HTML elements, spaces are a special separator character for HTML element attributes like
type,value, etc.When printing attribute values without doublequotes like follows
then the generated HTML ends up as
All parts beyond the space are been interpreted as another attributes. A bit intelligent syntax highlighter should already have turned on some light above your head. It’s colored differently!
So, you need to put quotes around the value
so that the generated HTML ends up as
Unrelated to the concrete problem, using scriptlets is discouraged, you should prefer using taglibs/EL. Assuming that you’ve put the
affectedBeanas attribute of the request, do so: