Shows the demonstration of page directive to import java classes,get the hostname through predifined HttpServletRequest variable,access count since last reboot of machine, use of jsp:useBean Directive, class named Man and MysqlConn must exist in package pack and loads the list from the mysql database.
<%@ page import = "java.util.*,pack.MysqlConn,java.sql.*" %>
Current Date <%= new java.util.Date() %>
Remote Host <%=request.getRemoteHost() %>
<%! private int remoteAccess=0; %>
Access Count :<%= ++remoteAccess %>
angle bracket jsp:useBean id="test" class="pack.Man" scope="page"/ angle bracket
angle bracketjsp:setProperty name="test" property="empName" value="Maheswor Prajapati" /angle bracket
angle bracketjsp:setProperty name="test" property="address" value="bkt"/angle bracket
angle bracketsp:setProperty name="test" property="gender" value="male"/angle bracket
Name: angle bracket jsp:getProperty name="test" property="empName" /angle bracket
Address :angle bracketjsp:getProperty name="test" property="address" /angle bracket>
Gender: angle bracketjsp:getProperty name="test" property="gender" /angle bracket
<%! ResultSet set=null; %>
<%
MysqlConn con=new MysqlConn();
set=con.getEmp();
%>
The output is:
begin select tag
<%
while (set.next()){
%>
begin option tag value='<%=set.getString(1) %>' ><%=set.getString(2)%> end option tag
<%
}
%>
end select tag
No comments:
Post a Comment