♠ Posted by Unknown in Adv Java at 08:31
Java Server Page Directive
This example is showing the use of directives to import libraries of java into java server page code. Here, I have called util package of java library to fetch data from the html table.
<%--
Write a JSP program to implement the concept of directives. --%>
<%-- Fetchin gthe data from an HTML
form. --%>
<%-- This JSP also generates the form.
--%>
<%-- Below is a JSP Directive --%>
<%@ page import =
"java.util.*" %>
<HTML>
<BODY>
<H1>Display
Form data</H1><H3>
<%
Enumeration
flds = request.getParameterNames();
if(!flds.hasMoreElements())
{ %>
<FORM
METHOD = "POST" ACTION = "Practical30.jsp">
<%
for(int i=0; i<10; i++){ %>
Field
<%= i %> :
<INPUT
TYPE = "TEXT" SIZE = "20" NAME =
"Field<%=i%>" VALUE = "Value<%=
i%>"><BR>
<%
} %>
<INPUT
TYPE = "Submit" NAME = "Submit" VALUE = "Submit"></FORM>
<%} else {
while(flds.hasMoreElements())
{
String
field = (String) flds.nextElement();
String
value = request.getParameter(field);
%>
<LI><%=
field %> = <%= value %> </LI>
<%
}
}
%>
</H3>
</BODY>
</HTML>
0 comments:
Post a Comment