welcome to JSP Servlets 26/03/2021
***This Document can be found at URL:***
https://hackmd.io/@amittiwari/SyPkcWjEd
Provide feedback on this
https://www.menti.com/96764mwy8h
Next batch ID
15907
get nominated and enrolled
Do not edit anything else apart from QnA Section
***Please List down your questions below ,
We will try to answer as much as possible***
Why ?
can you pls repeat why jstl and request dispatcher is used?
what is the best type of redirection as a login application?
Hi Sir Please can you send us demo project
#############Do Not Edit below###################
Step 1 Local Setup
Use IDE of your choice + Tomcat Server
Step 2 start a blank tomcat server and check the default homepage is working .
Step 3 Create a new Project
Choose Dynamic Web Project
Make sure to select web.xml also known as deployment descripter
Context is>> name project name
web content directory >> this where our HTML JSP Javascript goes
Step 4 >> Create a Welcome file
Step 5 >> start server see the welcome file (demo1)
Step 6 >> create a servlet (Demo2)
Run the servlet check output?
What are request Response objects?
What is URL pattern?
Step 7 Xml Configuration (Demo3)
why xml config required?
Annotations were introduced in java5
any changes done in xml file we need to restart tomcat
```
<servlet>
<servlet-name>xmlServlet</servlet-name>
<servlet-class>com.tcs.session.XmlServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>xmlServlet</servlet-name>
<url-pattern>/xmlServletApp</url-pattern>
</servlet-mapping>
```
Get calls are used to get data << database
Post calls are used to Post data >> database
UI >> get call >> Microservice >> vendor application
Step 8 POST methods
How to paas URL paramters? (Demo4)
Paas 2 paramters?
How to paas Post parameters (HTML forms) (Demo5)
What is the difference between URL and POST params
Step 9 When to use Get when to Post
Params are shown in url paramters
Multiple Hits
Step 10 Scopes and Objects ppt (Demo6)
what are Request Response Servlet objetcs?
Who creates these objects?
where do they run?
classes we use are Tomcat implementations
Scopes of these objects
req res are per access
Sevlet is not created per access
Why is Request object not reused?
Step 11 How to use user data for future requests?
what is session object
usecases login screen shopping carts
session object is one per user available across requests
Step 12 Use accross user accros browser
Usecase : initialization code like db connection , common bulletien board
what is context Object?
Step 13 : Init and service methods
Step 14 intro to JSP
tough to run HTML in Servlet
idea is to decouple View and Business logic
ispite of having java contain html
we do HTML containing java
Step 15 how to mark java code
<%%> >> code goes to java file >> doGet()
<%!%>
ALl JSP convert to servlet
all scriplets get converted to doget method
Step 16 page directive used to set values for entire JSP page
Step 17 passing parameters
Step 18 MVC pattern
```
Component for MVC demo plain redirect
Controller
LoginServlet
Sevice
AutheticationService
Model
Auth result
View
Success or redirect
Send data with model
```
Plain redirect
Browser redirect
Serverside redirect