Escolar Documentos
Profissional Documentos
Cultura Documentos
1. Java Server Pages or JSP for short is Sun's solution for developing dynamic web
sites. JSP provide excellent server side scripting support for creating database
to embed java code in html pages. JSP files are finally compiled into a servlet by the JSP
engine. Compiled servlet is used by the engine to serve the requests.
in the JSP pages (custom tags allows us to defined our own tags).
Example: <%@ taglib uri="tlds/taglib.tld" prefix="mytag" %>
and attribute may be:
1. language="java"
This tells the server
that the page is using the java language. Current JSP specification supports only
java language.
Example: <%@page language="java" %>
2. extends="mypackage.myclass"
This attribute is used when we want to extend any class. We can use comma(,) to
import more than one packages.
Example: <%@page language="java" import="java.sql.*,mypackage.myclass"
%>
3. session="true"
When this value is true session data is available to the JSP page otherwise not. By
default this value is true.
Example: <%@page language="java" session="true" %>
4. errorPage="error.jsp"
errorPage is used to handle the un-handled exceptions in the page.
Example: <%@page language="java" session="true" errorPage="error.jsp" %>
5. contentType="text/html;charset=ISO-8859-1"
Use this attribute to set the mime type and character set of the JSP.
Example: <%@page language="java" session="true"
contentType="text/html;charset=ISO-8859-1" %>
1. Scriplets
In this tag we can insert any amount of valid java code and these codes are placed
in _jspService method by the JSP engine.
2. Expressions
We can use this tag to output any data on the generated page. These data are
automatically converted to string and printed on the output stream.
• jsp:include
The jsp:include action work as a subroutine, the Java servlet
temporarily passes the request and response to the specified JSP/Servlet. Control
is then returned back to the current JSP page.
• jsp:param
The jsp:param action is used to add the specific parameter to current request.
The jsp:param tag can be used inside a jsp:include, jsp:forward or jsp:params
block.
• jsp:forward
The jsp:forward tag is used to hand off the request and response to another JSP
or servlet. In this case the request never return to the calling JSP page.
• jsp:plugin
In older versions of Netscape Navigator and Internet Explorer; different tags is
used to embed applet. The jsp:plugin tag actually generates the appropriate
HTML code the embed the Applets correctly.
• jsp:fallback
The jsp:fallback tag is used to specify the message to be shown on the browser if
applets is not supported by browser.
Example:
<jsp:fallback>
<p>Unable to load applet</p>
</jsp:fallback>
• jsp:getProperty
The jsp:getPropertyB is used to get specified property from the JavaBean object.
• jsp:setProperty
The jsp:setProperty tag is used to set a property in the JavaBean object.
• jsp:useBean
The jsp:useBean tag is used to instantiate an object of Java Bean or it can re-use
existing java bean object.
• request:
request represents the clients request and is a subclass of HttpServletRequest. Use
this variable to retrieve the data submitted along the request.
Example:
<%
//java codes
String userName=null;
userName=request.getParameter("userName");
%>
• response:
response is subclass of HttpServletResponse.
• session:
session represents the HTTP session object associated with the request.
• out:
out is an object of output stream and is used to send any output to the client.
Example
Till now you learned about the JSP syntax, now I will show you how to create a simple
dynamic JSP page that prints the current date and time. So the following code
accomplish this:
Now I will show you how to retrieve the data posted from a HTML file in a JSP page.
Consider an html page that prompts the user to enter his/her name, let's call it
getname.htm. Here is the code of the html file:
<html>
<head>
<title>Enter your name</title>
</head>
<body>
<p> </p>
<form method="POST"
action="showname.jsp">
<p><font color="#800000" size="5">Enter
your name:</font><input type
="text" name="username" size="20"></p>
The target of form is "showname.jsp", which displays the name entered by the user. To
retrieve the value entered by the user we uses the
request.getParameter("username");
code.
<%@page
contentType="text/html" %>
<!--
http://www.roseindia.net/jsp
-->
<html>
<body>
<p><font size="6">Welcome :
<%=request.getParam
eter("username")%></font></p>
</body>
</html>
need popup calender
Hi, I need a pop up calender Accessing database from JSP
code in html, but i guess In This article I am going to discuss the
javascript would be needed connectivity from MYSQL database with
for event handling . I need a JSP.we take a example of Books
co database. This database contains a
table named books_details.
project guidance
i have to make a project
on resume management
Fill the book name and author fields and press Submit button. A page will open and
wherein a company can authors like...
select a candidaite based
on the data fed by him on
change password
servlets
hi all, i need the codes to
create a change password
servlet.
how to produce halftone
shares?
Respected sir, I'm a B.E
final year student doing
my project in halftone
visual cryptography.
open source
hi! what is open source? i
heard that SUN has
released open source
.what is re requisite to
understand that open
sourc
converting image to
byte[]
Dear Sir Can you please
tell me a solution for
converting a
java.awt.Image to byte[]
eg: java.awt.Image
java
java TestClass WHAT IS
THE ARGUMENT
PROVIDE BY JVM
WHILE WE RUN A
CLASS
FILE.DEFINATELY
NOT NULL.THEN
WHAT IS IT.
JSP
Hi! I am doing a project
in JSP called "SMS
schedule Reminder"... In
this i have to store the
user schedules and i h
Connection.close() issue
Hi, I connected to
MySQL with InnoDB as
a database through My
JDBC Application. Once