1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)

JSP Tutorials

JSP tags

There are five main tags:

1) Declaration tag :

You can declare any variable and you can write any method also. This method is accesible in the JSP.
Between these <%! %> you can put anything and that will placed into converted servlet.

public int getValue(){
int j=9;
return j;


In the JSP you can use the method like
In the converted servlet you have public method name : public int getValue(){}

2) Expression tag :
Syntax of JSP Scriptles are with <%= and ends with %>. Between these this you can put anything and that will converted to the String and that will be displayed.

In the JSP if you want to display the value of i.
Date : <%= new java.util.Date() %>

3) Directive tag :

There are three main types of directives:
a) page - processing information for this page.
<%@ page import = "java.util.*" %>
language :
Which language the file uses.
<%@ page language = "java" %>

extends :
Superclass used by the JSP engine for the translated Servlet.
<%@ page extends = "com.test... %>

Import all the classes in a java package into the current JSP page. This allows the JSP page to use other java classes.
<%@ page import = "java.util.*" %>

session :
Does the page make use of sessions. By default all JSP pages have session data available. There are performance benefits to switching session to false.
By default <%@ page session="true" %>

buffer :
Controls the use of buffered output for a JSP page. Default is 8kb

<%@ page buffer = "none" %>

autoFlush :
Flush output buffer when full.
<%@ page autoFlush = "true" %>

isThreadSafe :

Can the generated Servlet deal with multiple requests? If true a new thread is started so requests are handled simultaneously.
By Default :<%@page isThreadSafe="true" %>

info :
Developer uses info attribute to add information/document for a page. Typically used to add author,version,copyright and date info.

<%@ page info = "techfaq360.com copyright 2008. " %>

errorPage :
Different page to deal with errors. Must be URL to error page.

<%@ page errorPage = "error.jsp" %>

IsErrorPage :

This flag is set to true to make a JSP page a special Error Page.
<%@ page IsErrorPage = "true" %>

contentType :
Set the mime type and character set of the JSP.

b) Include - files to be included.
to include a header.jsp found in the current directory
<%@ include file = "header.jsp" %>
c) Tag library - tag library to be used in this page
A tag lib is a collection of custom tags that can be used by the page.

<%@ taglib uri = "tag library URI" prefix = "tag Prefix" %>

4)Scriptlet tag :

//java codes

int i = 6;

i = i+9;


JSP Scriptlets begins with <% and ends %> .We can embed any amount of java code in the JSP Scriptlets. JSP Engine places these code in the _jspService() method.

5)Action tag :
There are three main roles of action tags :
a)enable the use of server side Javabeans
b)transfer control between pages
c)browser independent support for applets
To use a Javabean in a JSP page use the following syntax:

<jsp : usebean id = "test" scope = "application" class = "com.tech.Test" />

Reviews and Comments

PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc

Copyright © www.techfaq360.com 2016

About US | Contact US | Privacy Policy | Terms and Conditions  | Website disclaimer  | Cancellation and Refund Policy  | Shipping & Delivery Policy