java advance few topics, Study notes of Java Programming

advance java few topics, including jsp, servlet etc

Typology: Study notes

2017/2018

Uploaded on 07/30/2018

ankush-singh
ankush-singh 🇮🇳

1 document

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ServletRequestInterface:-
servlet interface is an interface which is used to get request information to the servlet
1. content type
2.content length
3.header name
4.parameter names and values
5.and attribute
Requset Dispatcher Interface
It is an interface which is used to dispatch the request to another resource it can be html
file or jsp file or another servlet.
they have 2 method:
1. forward:-
2. include
*******************12/07/2018:-*****************
sendRedirect is the predefined method of HTTP servlet response interface it is used to
redirect one servlet to the another resourese
that another resourse can be jsp,servlet, html page.
It always works on the client side.
ServletConfig is an interface which is used to get configuration information from
web.xml file.
The object of servlet config is created for each servlet.
If we do any modification in web.xml file no need to change the servlet.
Session:-
Session is a particular interval of time
to identify the particular user we use session management.
Session Management techniques:-
1. cookie- Cookie is small piece of information which persist between multiple client request.
Cookie has a name, value, maximum age, and version number.
Whenever the client send the request cookie is added with the response and it is
stored in the cached of the browser. so whenever the same user login it
automatically
added with the request. this is how particular user is identified
There are 2 types of cookies:
1. non persistent:- valid only for single session. whenever the user closes
the browser it will go
2. persistent- it is valid for multiple sessions. it will go whenever the
user will logout.
Advantages:-1. it is a very easy way to maintain the state of the user
2. cookies are maintained at client side
Disadvantages:-1. it will not work if the cookie is disabled from browser.
2. only textual information can be sent.
pf3
pf4
pf5

Partial preview of the text

Download java advance few topics and more Study notes Java Programming in PDF only on Docsity!

ServletRequestInterface:-

servlet interface is an interface which is used to get request information to the servlet

  1. content type 2.content length 3.header name 4.parameter names and values 5.and attribute

Requset Dispatcher Interface

It is an interface which is used to dispatch the request to another resource it can be html file or jsp file or another servlet. they have 2 method:

  1. forward:-
  2. include

sendRedirect is the predefined method of HTTP servlet response interface it is used to redirect one servlet to the another resourese that another resourse can be jsp,servlet, html page. It always works on the client side.

ServletConfig is an interface which is used to get configuration information from web.xml file. The object of servlet config is created for each servlet. If we do any modification in web.xml file no need to change the servlet.

Session:- Session is a particular interval of time to identify the particular user we use session management.

Session Management techniques:-

  1. cookie- Cookie is small piece of information which persist between multiple client request. Cookie has a name, value, maximum age, and version number. Whenever the client send the request cookie is added with the response and it is stored in the cached of the browser. so whenever the same user login it automatically added with the request. this is how particular user is identified

There are 2 types of cookies:

  1. non persistent:- valid only for single session. whenever the user closes the browser it will go
  2. persistent- it is valid for multiple sessions. it will go whenever the user will logout. Advantages:-1. it is a very easy way to maintain the state of the user
  3. cookies are maintained at client side

Disadvantages:-1. it will not work if the cookie is disabled from browser.

  1. only textual information can be sent.
  1. hidden form filled:- In hidden form filled one invisible field is created to mantain the state of the user.

Advantage- 1. it will always work if cookei will desable or not

dis- 1. it will work on server side

  1. only textual information can be sent.
  2. url rewriting- In this techniques we append token or identfier to the url of next resource.
  3. http session-In this sessionID is created for each user. and this id is used to identify the user. with the use of http session
  4. we can bind the object
  5. we can get the information about session creation time, last access tikme and w can do the manipulation also

ServletContext:- ServletContext is an interface which is used to get configuration information from web.xmlfile Object of servletcontext is created for each page. We will use context param tag to get the information. It is used whenever we have to share the information to all the servlets If we do any modification in web.xml file no need to change the servlet.

******************************* JAVA SERVER PAGES:-

JSP is extension to servlet it is also used to create, web applocations like servlet it is the combination of html tag and jsp tags. it separates the business logic from design Advantages:-

  1. Easy too maintain
  2. it is extension to servlet
  3. no need to redeploy and recompile

two packages

  1. javax.servlet.jsp.; 2. javax.servlet.jsp.tagext.;

JSP LIFE CYCLE:-

  1. jspInit()
  2. _jspService()----[ this method cannot be overriden, that's y we use _ sign]
  3. jspDestroy()

The classes are as follows:-

  1. JspWriter
  2. PageContext
  1. page directives- These are applied on the wholepage

a. import contentType extends info buffer language isELIgnored isThreadSafe autoFlush session pageEncoding errorPage isErrorPage

  1. include directives- is used whenever we have to include any resourse it can be html file,jsp file, or servlet
  2. tag lib directives-these directives are used to define the tag library. we use tld(tag library descripters) to define the tag. syntax= <%@directive attribute="value"%>

syntax of page directive:- <%@page attribute="value"%>

Bean is a class which should implements serializable interface. It can have getter an setter methods. It should not no argument constructor.

Use bean is used to instantiate the bean class.