Thursday, November 6, 2008

how we can deal with JSP

We have mentioned that what we do in a jsp is write java codes inside a html page or rather html tags. for that purpose there are several ways to do so which we will learn now onwards. Two major ways are found in doing so. They are

· Scripting

· Xml based tags and EL(Expression Language)

We will talk about these seperately. First we’ll talk about Scripting. Scripting is the way to write pure Java code inside html page. We can place our java code in this way <% some java code%>. The <% %> element is called a scriptlet. The web container identifies this and seperate java codes from html when the jsp page translation is done. This is very usefull for a developer who is familiar only with java and who can make the UI (user Interface) himself.





We can use many scripting elements in our jsp page. And also we can use html tags even inside these scriptlets in this way.

This will generate five text boxes in the jsp page. There are some more to learn in scripting. Lets discuss that in the next chapter.

Monday, November 3, 2008

what is a JSP

JSP stands for Java Server Pages. The need of this type of a thing came to the java world because it was a burdent of writing html in side java classes which are servlets. There we had to do our html part inside javas out.println(""); methods. But in jsp we have a dynamic behaviour with java and we use java inside html pages which have an extension of .jsp. This supports a lot to web designers who design the UI part which must be interactive rather than the functionalities of a developers parts.
In the life cycle of a jsp it becomes a servlet and ends with a .class file. First the jsp translates and then it compiles. Then as same as a servlet its jspInit() method (in servlets it is init()) runs and it is instantiated. Then all the requests for this are handled by the _jspService() method. and when this is going to end(life cycle) the jspDestroy() method runs. we can override the jspInit() and the jspDestroy() methods for our purposes which we will discuss later. but we cant override the _jspService() method.
As we are familliar with html we have to know how we can write java inside these html pages. We will discuss that in the next section.

****
for servlets visit http://myservlet.blogspot.com
****