Embed
Email

JSP and Java Servlets

Document Sample

Shared by: dandanhuanghuang
Categories
Tags
Stats
views:
1
posted:
12/5/2011
language:
English
pages:
2
JSP and Eclipse



1. Using Eclipse integrated with Oracle and Tomcat

a. Apache Tomcat install directory:

C:\apache-tomcat-5.5.xx



2. We will be using Apache Tomcat 5.5, which as been

integrated with eclipse. See notes from in-class exercise

inclassHTML.doc



3. jsp is used primarily for presentation. Think of it is

HTML with embedded Java code.

a. jsp files have extension .jsp

b. html comment: , passed to client

jsp comment: , not passed to client

c. java scriptlets text in here is not

sent to the web server unless you use

i. out.print(“—“);

ii. out.println(“—“);

d. it evaluates the expression

and sends it to the web server

e. inserted into body of

servlet class outside any method.

f. jsp Directives: (import

java classes or insert text of an other file)

g. jsp Action: (include file or html

output e.g., header.html)





Note the output of the html file is included in the

jsp file.

h. All other text (HTML is passed straight to client/web

server)

i. Like php you can move in and out of java scriptlets



4. Your JSP page generates a servlet object that has a

method called _jspService. All scriptlet code goes in

this method. The method also has some predefined local

variables (e.g., request, response, out). You can use the

request variable to get values sent by a form.

a. request.getParameter(“param1”) returns a String

b. request.getParameterValues(“param”) returns an

array of String (e.g., String[])

i. The same control name appears more than once

in the form (e.g., checkbox example)

5. More on Directive: We will use a Utility class to open and

query the database. This class must be in a package (see

Servlest and JavaServer Pages – Hall and Brown page 355).

We will use the directive







You can use the include directive to insert text from a

file.



This acts as if the actual text from someFile was

inserted at this point. Usually should not use this

command



6. With an Eclipse Dynamic Web Project the directory

WebContent will contain the html and JSP files. All java

classes (e.g., Utility.java) are in the directory src

(and should be in a package).



a. You should thoroughly test the methods in Utility.java

before integrating them (i.e., using them) with jsp.

Write a UtilityTest.java program to test all the

methods in Utility.java



Related docs
Other docs by dandanhuanghua...
CSCE_Postgrad_Research_Students_Guidelines
Views: 0  |  Downloads: 0
F
Views: 6  |  Downloads: 0
SDS_User_Manual
Views: 3  |  Downloads: 0
systémy - FEL wiki
Views: 0  |  Downloads: 0
Alan Kalter - Bio 020812
Views: 0  |  Downloads: 0
Battery Balancer - Control Board
Views: 0  |  Downloads: 0
cocuk_1_erkekler
Views: 0  |  Downloads: 0
CARLSON.TESTIMONY
Views: 0  |  Downloads: 0
New_York_2011_info_letter_1_
Views: 0  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!