Professional Documents
Culture Documents
. The Request Dispatcher dispatches the client request to another web resources,
. it has2 methods
. when this method is called,the control,the control is transferred to the next resources called
.when this method is called ,the control still remains with the calling resources
Servletconfig:-
The servlet config is an object containing server initial parameret createdby servlet config
for a particular servlet and the initial parameters are servlet specific
<servlet>
<servlet-name>user servlet</servlet-name>
<servlet-class>user servlet</servlet-class>
<init-param>
<param-name>username</param-name>
<param-value>subrat</param-value>
</init-param>
</init-param>
<param-name>email</param-name>
<param-value>subratjena@gmail.com</param-value>
</init-param>
<servlet>
. context parameter refers to the initialization parameter for all servlet of an application.
<param-name>,<param-attribute>.
. <param-name> contains the name of the parameter& <param-value>contains the value of the
parameter.
<context-param>
<param-name>username</param-name>
<param-value>tul.ka</param-value>
.</context-param>
.<context-param>
<param-name>email</param-name>
<param-value>subrat@hbdjghgafhab gmail.com</param-value>
.</context-param>
Super.init(config);
Out.println(‘<html><)
Email= context.getInitParameter(“email”);
PrintWrite out=response.getWrite();
out.println(“<html><head><title>Servlet Context Page</title></head>”);
out.println(“</body></html>”);
SESSION TRACKING
Session- A particular interval of time.
COOKIES
IT IS A SMALL PIECE OF INFORMATION THAT IS PERSISTED B/W THE MULTIPLE CLIENT REQUEST.
.cookies name
.cookies value
EX.
.response.addcookies(cookies);
. Servlets’s HttpSession interface provides a way to identify a user in multiple page request.
.Ex. ServletOne.java
Cookies end on the lifetime set by When the user quits the browser or logs out of
the user. the programmed, the session is over.
Cookies are not secured. Session are more secured compare than cookies.
Cookies stored data in text file. Session save data in encrypted form.
Cookies stored on a limited data. Session stored a unlimited data.
We can set an expiration date to In PHP, to destroy or remove the data stored
delete the cookie’s data. It will within a session, we can use the session_destroy()
automatically delete the data at function, and to unset a specific variable, we can
that specific time. use the unset() function.
MVC ARCHITECTURE
.A Design pattern
.view---looka at model and generate an appropriate user interface to present the data.
.ex.
Model—java beans,
WHAT IS JSP ?
. Mostly html page,with html.jsp
. Dynamic content: The information generated and displayed at run time is called “dynamic content” jsp uses java to display dynamic content
. Execution Req
<%@page contentType=”text/html”pageEncoding=”UTF-8”%>
1.@PAGE
2.@INCLUDE :
. include another resources (jsp / html / servlet) into the current page
<%@include file = “sample.html”%>
1. DECLARATION:<%!...%>
. For Page wide variable and method declarations.
EX.--<% Int num%>
2.
.3 Expressions
.Formats expression valude I nto string in the output in thw web page
Ex.
4.Comments:
. to add user documented comments will not parsed by the jsp compiler.
Action tags
JDBC AP
.HIBERNATE COMPONENTS
.Hibernate.cfg.xml file:
.hibernate.cfg.xml file contains database related configuratyuon
And session related configuration.
.database configuration includes database connection URL, database user credentials, driver
class and hibernate dilect.
. <classname>.hbm.xml file;
<classname>.hbm.xml :the files spe ifies the mapping b/w POJO classes variables and table
column.
. it represented in the “hibernate” . cfg.xml.
Spring Framework:
A Software framework is re usable design for a software system.
Application Framework:
.NON-Invaise --- Need to use the built in class and overriding the methods
.Light weight – Light weight frame work doesnot depend on class to hook components into them!
.flexible-User will define method in a single controller instead of having lifecycle mrthod (for servlet)
.Do not usen everything of spring – Based on the need the module are used in application.
Inversion of control
Set(B)
Object B
OBJECT A
OBJECT C
The act of Dependency
Spring Core Container
Spring’s container uses IoC manages components of the application.
. Application
Context (org.springframework.context.ApplicationContext provide application framework
service.
CONSTRUCTOR INJECTION
We can inject the dependency (Adress) by the constructor
Setter injection
Scenerio : Employee HAS-A-Adress
The address class object will be termed as thr dependent object.
Thye Employee class object will be termed as dependency.
ANNOTATIONS
Annotion are the instruction for the computer.
Also known asmetadata/datya about code
Ex:
@override
Checks that the method is available in the super class
EX:
@Override
Public String to String(){
return “Welcome!”;
}
Annotation are used to avoid configuration of certain tags in Xml files in frameworks.
They Wont affect the normal application flows.
@Auto wired
Auto wired annotation is used to inject a bean automatically without using ref attribute
Ex:
Webpage will become light weight after conversion of dynamic page into static page.
<servlet-name>spring</servlet-name>
<url-pattern>*html</url-pattern>
Based on the Servlet Mappings which we provide in our web.xml, the request will
be routed by the Servlet Container to our DispatcherServlet.
Once the request is received, the DispatcherServlet will take the help
of HandlerMapping which has been added in the Spring Configuration file and
get to know the Controller class to be called for the request received.
Now the request will get transferred to the Controller, the Controller then executes
the appropriate methods and returns the corresponding ModelAndView object to
the DispatcherServlet.
The DispatcherServlet will send the Model received to the ViewResolver to get
the view page.
Finally, the DispatcherServlet will pass the Model to the View page and the page
will be rendered to the user.