0% found this document useful (0 votes)
19 views

1203 Jsps

Java Server Pages (JSP) allow Java code to be embedded within HTML pages using specific tags. JSP files are converted to servlets upon first request, eliminating repetitive coding. Common JSP tags include <% %> to denote Java code blocks and <%= %> to output expressions. Implicit objects like request provide access to HTTP request data without declaration.

Uploaded by

vyshalli999
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

1203 Jsps

Java Server Pages (JSP) allow Java code to be embedded within HTML pages using specific tags. JSP files are converted to servlets upon first request, eliminating repetitive coding. Common JSP tags include <% %> to denote Java code blocks and <%= %> to output expressions. Implicit objects like request provide access to HTTP request data without declaration.

Uploaded by

vyshalli999
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Java Server Pages

(2005.04.20)

Java Server Pages

Java Server Pages


servlet variant Java code is embedded in HTML code via specific tags and compiled first time browsed similar to Active Server Pages, but not limited to Windows server eliminates repetitive coding

http://java.sun.com/products/jsp/ http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/

Java Server Pages

HTML JSP Tags


<% %> - start of Java code - end of Java code

<%= - evaluates expression, converts results to string and outputs it into HTML <%! - Java declaration

<%@ - followed by method, import, implements, extends <jsp: useBean ...\> - specify a Java Bean

Java Server Pages

JSP File
extension .jsp generally placed in root of Tomcat container in NetBeans converted to servlet by container upon first execution request

Java Server Pages

Quickie JSPs in NetBeans


1) mount the new file system 2) RMB on file system -> Tools -> Convert File System into Web Module 3) RMB on the mounted file system -> New -> All Templates -> JSPs & Servlets -> JSP 4) code the file 6) RMB on JSP file -> Execute; file will execute and be displayed in browser; any error information will be displayed in browser

Java Server Pages

Example JSP
<%@page contentType="text/html"%> <html> <head><title>JSP Page</title></head> <body bgcolor="red" text="white"> <%-- <jsp:useBean id="beanInstanceName" scope="session" class="package.class" /> --%> <%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%> <CENTER> <H2> The date and time is: <br> <%= new java.util.Date() %> </H2> </CENTER> </body> </html>

Example JSP (continued)

Java Server Pages 7

Java Server Pages

Implicit Objects
object that is exists without declaration for example, the output stream object cout in C++ is declared in the library iostream

Java Server Pages

Implicit Object request


deals with input from HTML forms instance of ServletRequestWrapper class method getParameter returns the value from a variable passed to a JSP String getParameter(String form-variable-name) example of use:
String name = request.getParameter(name);

You might also like