Techniques for form editing
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.
Comment on this tutorial
- Data Science
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
Uploading a file to a server using JSP
Uploading an Image to a Database using JSP
A JSP page that gets properties from a bean
The taglib, tag, include, attribute and the variable Directive in JSP
Scriptlets and Expressions in JSP
Querying Data with the JSTL in JSP