JavaBeat
Struts Tutorials | Hibernate Tutorials | JSP Tutorials | Servlet Tutorials | EJB Tutorials | Struts Resources | Spring Resources | Hibernate Resources
JSP Home Articles Resources Tutorials FAQs Forums  

1. Getting familiar with your JSP server

2. Your first JSP

3. Adding dynamic content via expressions

4. Scriptlets

5. Mixing Scriptlets and HTML

6. Directives

7. Declarations

8. Tags

9. Sessions

10. Beans and Forms Processing

11. Tag Libraries

12. Form Editing

13. Log-in pages

14. SQL

15. Sending Email

16. Further learning

Techniques for form editing

A tag library such as the one that comes with the Blazix 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="UserData" scope="session"/>
<HTML>
<BODY>
<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() %>>
<P><INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
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 datatype yourself.  This will allow you to handle exceptions.

Exercise:  Modify the earlier example to do everything without the Blazix tag library (you can restrict this to only one field.)


Sponsors
Webmaster Hosting Forum
Java Jobs
MyVideoLib
India News
Internet Advances
Latest QnA
Describe the lifecycle of a receiver application in order to receive a message?
Messages are not successful until they have been acknowledged. What are the types of acknowledgments?
What happens to messages if a transaction is rolled back?
What is the Role of the JMS Provider?
What is JMS administered object ?

JavaBeat Media (2004-2008), India
javabeat | planetoss | links directory | advertise
Copyright (2004 - 2008), JavaBeat