Sunday, April 12, 2009




Saturday, April 11, 2009

1. Introduction to JSP

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 driven web applications. JSP pages are high level extension of servlet and it enable the developers 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.

Thursday, April 9, 2009

2. INTRODUCTION TO JSP TAGS

Another important syntax element of JSP are tags.A JSP tag is somewhat like an HTML tag. JSP tags can have a "start tag", a "tag body" and an "end tag". The start and end tag both use the tag name, enclosed in < and > characters. The end starts with a / character after the < character.

Wednesday, April 8, 2009

3. Scriptlet Tag

In this tag we can insert any amount of valid java code and these codes are placed in _jspService method by the JSP engine.
a scriptlet - which means Java code within a <% .... %>

Eg : BasicCounter.jsp
<html> <body>

The Page Count is : <% out.println(Counter.getCount()); %>
</html> </body>


output

The page count is :1

Tuesday, April 7, 2009

4. Expression Tags

Expression tags automatically prints out what ever inside the Expression tags.Expressions become an arguments to the out.println()In other wors, Container takes everything inside the <%= and %> and puts it in as the argument to a statement that prints to the implicit response PrintWriter
Eg : When the Container sees this :
<%= TestCounter.getCount() %>

It turns it into this :
out.print(TestCount.getCount());

Monday, April 6, 2009

5. What REALLY happens to your JSP code

Container translate your JSPcode into a Servlet.
Note : IF you want to see the generated servler code from Tomcat :
yourTomcatHomeDir/work/Catalina/yourServletName/yourWebAppName/org/appache/jsp

All Scriptlet & Expression code lands in a service() method. i.e : varibles declared in a scriptlet are always LOCAL variable.