Beruflich Dokumente
Kultur Dokumente
Client/Server Network
1
Introduction:-jsp
A JSP page is a page created by the web
developer that includes JSP
technology-specific and custom tags,
in combination with other static
(HTML or XML) tags.
JSP engine
Servlet Container
Process of a JSP page
JSP Tags:-
Directive: ex: import classes
<%@ page import = java.util.* %>
Output:
<%= age %>
<%= new java.util.Date() %>
<%for(int i=0;i<3;i++){%>
<TR>
<TD> <%=item[i]%> </TD>
<TD> <%=price[i]%> </TD>
<TD> <%=quantity[i]%> </TD>
<TD> <%=price[i]*quantity[i]%> </TD>
</TR>
<%}%>
</TABLE>
</BODY>
</HTML>
3-Tier Architectures
Definition: A 3-tier architecture is one which has
a client tier, a middle tier, and a database tier.
The database tier manages the database
The middle tier contains most of the logic and
communicates between the other tiers
The client tier is the interface between the user and
the system
<HTML>
<HEAD><TITLE>Example of forward action</TITLE></HEAD>
<BODY>
<%if(math.random()>5){%>
<jsp: forward page = fibonaccicomputation.jsp/>
<%else{%>
<jsp: forward page = factorialcomputation.jsp/>
<%}%>
</BODY>
</HTML>
<html>
<head></head>
<body>
<p>Enter two numbers and click the
calculate button.</p>
Login.html
<HTML> <BODY>
<FORM ACTION=login.jsp METHOD=POST>
<P>USER NAME:<INPUT TYPE=text NAME=username>
<P>USERNAME:<INPUT TYPE=text NAME=password>
<P><INPUT TYPE=submit VALUE=Submit>
</FORM>
</BODY> </HTML>
JSP that verifies login password(login.jsp)
<HTML> <BODY>
<% ! final static int MIN_PASW_LEN=8;
boolean verifylength(string password)
{ if(password.length() < MIN.PASW_LEN)
return false;
return true;
}
boolean verifydigit(string password)
{ for(int i=0;i<password.length();i++)
{
if(Character.isDigit(password.charAt(i)))
return true;
}
return false;
}
boolean verifypolicy(String password)
{ if(verifylength(password) && verifydigit(password))
return true;
return false;
jsp:plugin Action Element
The jsp:plugin action can insert an Java Applet
client-side component into a server-side JSP page
component.
The syntax is as follows.
<HTML> <BODY>
<FORM ACTION=creditform.jsp METHOD=post>
Name: <INPUT TYPE=text NAME=name SIZE=10>
Credit cad no:<INPUT TYPE=text NAME=member SIZE=25>
Card type: <SELECT NAME=type>
<OPTION>Visa</OPTION>
<OPTION>Master Card</OPTION>
<OPTION SELECTED> Amex</OPTION>
</SELECT>
<INPUT TYPE =submit NAME=submit VALUE=submit>
</FORM>
</BODY> </HTML>
Processing request from the user
(a JSP code that process from that gathers credit card information creditform.jsp)
<html> <body>
<ul>
<li>name=<% =request.getparameter(name) %>
<li>name=<% =request.getparemeter(member) %>
<li>name=<% =request.getparameter(type) %>
</ul>
</body> </html>
JAVA Bean
package xyz;
public class callingjavabeanmethods
{ private String str; private int a ; private double d;
public callingjavabeanmethods(){}