InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.2: Developing JSP files >
JSP code example - EmployeeRepeatResults

JSP code example - EmployeeRepeatResults


<HTML>
<HEAD>
<TITLE>JSP Employee Results</TITLE>
</HEAD>
<H1><CENTER>EMPLOYEE RESULTS</CENTER></H1>
<BODY>

<% String userID      = request.getParameter("USERID"); %>
<% String passWord    = request.getParameter("PASSWD"); %>

<% String empno       = request.getParameter("EMPNO"); %>
<% String firstnme    = request.getParameter("FIRSTNME"); %>
<% String midinit     = request.getParameter("MIDINIT"); %>
<% String lastname    = request.getParameter("LASTNAME"); %>
<% String workdept    = request.getParameter("WORKDEPT"); %>
<% String edlevel     = request.getParameter("EDLEVEL"); %>

<!-- Get a connection to the local DB2 database using parameters from login.jsp -->

<tsx:dbconnect id="conn" url="jdbc:db2:sample" driver="COM.ibm.db2.jdbc.app.DB2Driver">
<tsx:userid><%=userID%></tsx:userid>
<tsx:passwd><%=passWord%></tsx:passwd>
</tsx:dbconnect>

<% if  ( ( request.getParameter("Submit")).equals("Update") ) { %>
<tsx:dbmodify connection="conn" >
INSERT INTO  EMPLOYEE
(EMPNO,FIRSTNME,MIDINIT,LASTNAME,WORKDEPT,EDLEVEL)
VALUES
( '<%=empno%>',
'<%=firstnme%>',
'<%=midinit%>',
'<%=lastname%>',
'<%=workdept%>',
<%=edlevel%>)
</tsx:dbmodify>
<B><UL>UPDATE SUCCESSFUL</UL></B>
<BR><BR>
<tsx:dbquery id="qs" connection="conn" >
select * from Employee  where  WORKDEPT= '<%=workdept%>'
</tsx:dbquery>


<B><CENTER><U>EMPLOYEE LIST</U></CENTER></B><BR><BR>
<HR>
<TABLE>
<TR VALIGN=BOTTOM>
<TD><B>EMPLOYEE
<BR>
<U>NUMBER</U></B></TD>
<TD><B><U>NAME</U></B></TD>
<TD><B><U>DEPARTMENT</U></B></TD>
<TD><B><U>EDUCATION</U></B></TD>
</TR>

<tsx:repeat>
<TR>
<TD><B><I><tsx:getProperty name="qs" property="EMPNO" /></I></B></TD>
<TD><B><I><tsx:getProperty name="qs" property="FIRSTNME" /></I></B></TD>
<TD><B><I><tsx:getProperty name="qs" property="WORKDEPT" /></I></B></TD>
<TD><B><I><tsx:getProperty name="qs" property="EDLEVEL" /></I></B></TD>
</TR>
</tsx:repeat>

</TABLE>


<HR>
<BR>
<% } %>

<% if  ( ( request.getParameter("Submit")).equals("Query") ) { %>

<tsx:dbquery id="qs2" connection="conn" >
select * from Employee  where  WORKDEPT= '<%=workdept%>'
</tsx:dbquery>


<B><CENTER><U>EMPLOYEE LIST</U></CENTER></B><BR><BR>
<HR>
<TABLE>
<TR>
<TR VALIGN=BOTTOM>
<TD><B>EMPLOYEE
<BR>
<U>NUMBER</U></B></TD>
<TD><B><U>NAME</U></B></TD>
<TD><B><U>DEPARTMENT</U></B></TD>
<TD><B><U>EDUCATION</U></B></TD>
</TR>

<tsx:repeat>
<TR>
<TD><B><I><tsx:getProperty name="qs2" property="EMPNO" /></I></B></TD>
<TD><B><I><tsx:getProperty name="qs2" property="FIRSTNME" /></I></B></TD>
<TD><B><I><tsx:getProperty name="qs2" property="WORKDEPT" /></I></B></TD>
<TD><B><I><tsx:getProperty name="qs2" property="EDLEVEL" /></I></B></TD>
</TR>
</tsx:repeat>
</TABLE>
<HR>
<BR>
<% } %>

</BODY>
</HTML>

Go to previous article: JSP .91 examples Go to next article: JSP code example - view employee records

 

 
Go to previous article: JSP .91 examples Go to next article: JSP code example - view employee records