By: aathishankaran Printer Friendly Format
A tag library such as the one that comes with the server may not be available in your environment. How can you allow similar features without using a tag library?
It is a little tedious, but it can be done. Basically, you must edit each HTML tag yourself, and put in a default value. The following examples shows how we modify GetName.jsp to provide features similar to blx:getProperty but with manual HTML tag editing:
<jsp:useBean id="user" class="user.UserData" scope="session"/>
<FORM METHOD=POST ACTION="SaveName.jsp">
What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20 VALUE="<%= user.getUsername() %>"><br>
What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20 VALUE="<%= user.getEmail() %>"><br>
What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4 VALUE=<%= user.getAge() %>><br>
As you can see, this simply involves adding a "VALUE" field in the INPUT tags, and initializing the field with an expression!
To handle exceptions during input processing, a simple approach is to use "String" fields in the bean, and do the conversion to the target data type yourself. This will allow you to handle exceptions.
Most Viewed Articles (in JSP )
Latest Articles (in JSP)
Comment on this tutorial
- Data Science
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews