InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.2: Developing JSP files >
4.2.2.3: Overview of JSP file content >
4.2.2.3.8: IBM extensions to JSP .91 syntax >
4.2.2.3.8.2: JSP .91 syntax: JSP tags for database access >
4.2.2.3.8.2.4: JSP .91 syntax: <DBMODIFY> tag syntax

4.2.2.3.8.2.4: JSP .91 syntax: <DBMODIFY> tag syntax

<!-- Any valid database update commands can be placed within the DBMODIFY tag. -->
<!-- Any other syntax, including HTML comments, are not valid. -->
<dbmodify connection="connection_id" >
</dbmodify>
where:
  • connection

    The identifier of a <DBCONNECT> tag in this JSP file. That <DBCONNECT> tag provides the database URL, driver name, and (optionally) the user ID and password for the connection.

  • Database commands

    Refer to your database documentation for valid database commands.

In the following example, a new employee record is added to a database. The values of the fields are based on user input from this JSP and referenced in the database commands using <INSERT> tags.

<dbmodify connection="conn" >
insert into EMPLOYEE
(EMPNO,FIRSTNME,MIDINIT,LASTNAME,WORKDEPT,EDLEVEL)
values
('<INSERT requestparm="EMPNO"></INSERT>',
'<INSERT requestparm="FIRSTNME"></INSERT>',
'<INSERT requestparm="MIDINIT"></INSERT>',
'<INSERT requestparm="LASTNAME"></INSERT>',
'<INSERT requestparm="WORKDEPT"></INSERT>',
<INSERT requestparm="EDLEVEL"></INSERT>)
</dbmodify>

The EmployeeRepeatResults.jsp example illustrates this tag.

Displaying query results

To display the query results, use the <REPEAT> and <INSERT> tags. The <REPEAT> tag loops through each of the rows in the query results. The <INSERT> tag uses the query results object (for the <DBQUERY> tag whose identifier is specified by the <INSERT> bean attribute) and the appropriate column name (specified by the <INSERT> property attribute) to retrieve the value. An example is:

<repeat>
<tr>
<td><INSERT bean="empqs" property="EMPNO"></INSERT>
<INSERT bean="empqs" property="FIRSTNME"></INSERT>
<INSERT bean="empqs" property="WORKDEPT"></INSERT>
<INSERT bean="empqs" property="EDLEVEL"></INSERT>
</td>
</tr>
</repeat>

JSP 0.91 APIs and migration

Two interfaces support the JSP 0.91 technology. These APIs provide a way to separate content generation (business logic) from the presentation of the content (HTML formatting). This separation enables servlets to generate content and store the content (for example, in a bean) in the request object. The servlet that generated the context generates a response by passing the request object to a JSP file that contains the HTML formatting. The <BEAN> tag provides access to the business logic.

The interfaces that supported JSP 0.91 for the Application Server Version 3 are:

  • javax.servlet.http.HttpServletRequest.setAttribute()

    Supports setting attributes in the request object. For the Application Server Version 2, this interface was com.sun.server.http.HttpServiceRequest.setAttribute().

  • javax.servlet.http.RequestDispatcher.forward()

    Supports forwarding a response object to another servlet or JSP. For the Application Server Version 2, this interface was com.sun.server.http.HttpServiceResponse.callPage().

Go to previous article: Example: JSP .91 syntax: <DBQUERY> tag syntax Go to next article: Example: JSP .91 syntax: <DBMODIFY> tag syntax

 

 
Go to previous article: Example: JSP .91 syntax: <DBQUERY> tag syntax Go to next article: Example: JSP .91 syntax: <DBMODIFY> tag syntax