Community Sites
Create your own community website and start earning today !
It's Free !
Forum
Resources
Mentors
Projects
Entrance Exams
Question Papers
Colleges
Courses
Universities
Schools
Make Money
Communities
Members
Bookmarks
Polls
Fresher Jobs
Funny Photos
B.Tech Projects
New Member FAQ
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
eldho
(200)
Anil
(103)
GLADWIN
(100)
Last 7 Days
Saagar
(1818)
sunil
(1772)
satish
(1735)
more...
Awards & Gifts
Online Exams
Aptitude Questions
General Aptitude Tests
Medical Entrance
Engineering Entrance
Bank Tests
TOEFL & IELTS Questions
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
JavaServer Pages
Posted Date: 25 Mar 2008 Resource Type:
Articles/Knowledge Sharing
Category:
General
Posted By:
rajasekhar
Member Level:
Gold
Rating:
Points
: 5
JSP (JavaServer Pages)
Why JSP Technology?
•Servlets are good at running logic
–Not so good at producing large amounts of output
–out.write() is ugly
•JSP pages are great at producing lots of textual output
–Not so good at lots of logic
–<% %> is ugly
How does it Work
•“JSP page”
–Mixture of text, Script and directives
–Text could be text/ html, text/ xml or text/ plain
•“JSP engine”
–‘Compiles’ page to servlet
–Executes servlet’s service() method
•Sends text back to caller
•Page is
–Compiled once
–Executed many times
Anatomy of a JSP
<%@ page language=“java” contentType=“text/html” %>
The following information was saved:
User Name:
Welcome!
JSP Elements
•Directive Elements : –Information about the page
–Remains same between requests
–E.g., scripting language used
•Action Elements : –Take action based on info required at request-time
•Standard
•Custom (Tags and Tag Libraries)
•Scripting Elements
–Add pieces of code to generate output based on conditions
Directives
•Global information used by the “JSP engine”
•Of form <%@ directive attr_ list %>
•Or
–Directive could be
•Page
•Include
•Taglib
–E. g.,
<%@ page info=“ written by DevelopMentor” %>
<%@ include file =“\ somefile. txt” %>
<%@ taglib uri = tags prefix=“ foo” %>
Actions Within a JSP Page
•Specifies an action to be carried out by the “JSP engine”
•Standard or custom
–Standard must be implemented by all engines
–Custom defined in tag libraries
•Standard actions ‘scoped’ by ‘jsp’ namespace
•Have name and attributes
The current date at the server is:
Date:
Month:
Standard JSP Actions :
•jsp:useBean
•jsp:getProperty
•jsp:setProperty
•jsp:include
•jsp:forward
•jsp:param
•jsp:plugin
Scriptlets
•Of form <% /* code goes here*/ %>
–Gets copied into _ jspService method of generated servlet
•Any valid Java code can go here
CODE: OUTPUT
<% int j; %>
0 value>
<% for (j = 0; j < 3; j++) {%>
1 value>
2 value>
<% out. write(""+ j); %>
value><% } %>
Declarations (<%! … %>)
•Used to declare class scope variables or methods
<%! int j = 0; %>
•Gets declared at class- level scope in the generated servlet
•
public class SomeJSP extends HttpServlet implements HttpJspPage {
…
int j = 0;
void _jspService(…) {}
}
Declarations (<%! … %>)
•Used to declare class scope variables or methods
<%! int j = 0; %>
•Gets declared at class- level scope in the generated servlet
•
public class SomeJSP extends HttpServlet implements HttpJspPage {
…
int j = 0;
void _jspService(…) {}
}
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
(No tags found.)
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
Realtors Project
Previous Resource:
Nature vs. Nurture: The Debate Over Skills or Competencies
Return to Discussion Resource Index
Post New Resource
Category:
General
Post resources and
earn money
!
Related Resources
Accent & Intonation
Unisys India Pvt Ltd hiring Network Engineer
Recruitment Manager
Blood Banks in Banglore
EXCELLENT OPPORTUNITIES IN SOFTWARE
Watch TV Channels
Watch Asianet online
Kairali TV in Internet
Surya TV online
Amritha TV Channel
Contact Us
Editors
Privacy Policy
Terms Of Use
SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.