SlideShare a Scribd company logo
Java ppt
Defination:
 servlet is a java class that extends the
functionality of web server.
Eg:
 mail server
servlet is a class that performs virus scan to attached files
Benefits
 only one copy of servlet is loaded into jvm.
 each request begins a new thread to servlet process.
◙ save time
◙ response time increases
◙ it is scalable
Java ppt
Java ppt
Servlet implementation:
 servlet use class and interface from 2 package
◘ javax.servlet
 It contains classes to support generic protocol
◘ javax.servlet.http
 It extends classes in servlet package to add HTTP sapecific
functionality.
Java ppt
Java ppt
Servlet API :
o Servlet interface
o Genericservlet class
o HTTPservletrequest interface
o HTTPservletrequest interface
o Cookie class
o HTTPsession interrface
o single threadmodel interface
o servletexception class
o unavailableexception class
o servlettcontext interfave
o serrvletconfig interrface
Servlet interface:
 Every servlet must implements the javax.servlet interface
 It can implement in 2 ways:
◙ Directly implementing interface
◙ Extending any of 2 classes:
◙ javax.serrvlet.genricservlet
◙ javax.servlet.http.HTTPservlet
Methods:
◘ Init()
◘ Service()
◘ Destroy()
◘ Getservletinfo()
◘ Getservletconfig()
Service()
syntax:
 public abstract voidservice(servletrequest req,
servletresponse res)throws
servletException,IOException
◙ it is called whenever the request is made
◙it must be overridden in servlet
◙ it receives request via servletrequest and sends
response via servlet response
HTTP servlet
 It is an abstract class that is used for developing
HTTpservlets.
 It dose not override the service() method.
 It override doget() to handle GET requests and dopost()to
handle POST requests
Java ppt
Methods:
o serrvice()
o doget()
o dopost()
o dodelete()
o dooption()
o do put()
o do trace()
do get() or do post()
o protected void doget(HTTPServletRequest req
HTTPServletResponse res)throws servletException,IOException
o protected void dopost(HTTP ServletRequest
req,HTTPservletresponse res) throws
servletException,IOException
public class SessionServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException
{
res.setContentType("text/html");
OutputStream out = res.getOutputStream();
PrintWriter pw = new PrintWriter(new OutputStreamWriter(out));
HttpSession session = req.getSession(false);
if (session == null) {
session=req.getSession(true);
session.putValue ("VisitCount", "1");
}
pw.println("<html><body><pre>");
pw.println("session.isNew()="+session.isNew());
pw.println("session.getCreationTime()="+ new java.util.Date(
session.getCreationTime()));
pw.println("session.getID()="+session.getId());
pw.println("session.getLastAccessedTime()=" + new
java.util.Date(session.getLastAccessedTime()));
String strCount = (String) session.getValue("VisitCount");
pw.println("No. of times visited = " + strCount);
int count = Integer.parseInt(strCount); count++;
session.putValue("VisitCount", Integer.toString(count));
pw.println ("</pre></body></html>");
pw.flush();
}
}
Java ppt

More Related Content

PDF
JUnit and Mockito tips
PDF
All bugfixes are incompatibilities
PDF
What's new in v11 - Fluentd Casual Talks #3 #fluentdcasual
PDF
HTTP/2 Server Push
PPTX
{ jscamp : "Hannam" } Qunit Test Automation using Hudson and Selenium - 김민종
PPTX
Async java8
PDF
Nginx وب سروری برای تمام فصول
PDF
Babushka
JUnit and Mockito tips
All bugfixes are incompatibilities
What's new in v11 - Fluentd Casual Talks #3 #fluentdcasual
HTTP/2 Server Push
{ jscamp : "Hannam" } Qunit Test Automation using Hudson and Selenium - 김민종
Async java8
Nginx وب سروری برای تمام فصول
Babushka

What's hot (17)

PDF
Glusterfs session #7 client, server interactions
PDF
톰캣 #04-환경설정
PPTX
Upgrading Puppet Agents
PPTX
Mule hppt java
PPTX
PPTX
Kotlin Coroutines and Rx
PDF
Akmal Khaleeq Waheed - Challenge 3 p2
PPTX
Qunit testing slider
KEY
Shibuya,trac セッション
PDF
Java 8 고급 (4/6)
PDF
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
PPTX
AMC Minor Technical Issues
ODP
Sockets in nach0s
ZIP
マイナーツールを使ってみる
PPTX
Running workflows through galaxy bosc presentation
PPTX
My mule esb first http flow
PPTX
Ruby version manager
Glusterfs session #7 client, server interactions
톰캣 #04-환경설정
Upgrading Puppet Agents
Mule hppt java
Kotlin Coroutines and Rx
Akmal Khaleeq Waheed - Challenge 3 p2
Qunit testing slider
Shibuya,trac セッション
Java 8 고급 (4/6)
Magento 2 Seminar - Miguel Balparda - M2 with PHP 7 and Varnish
AMC Minor Technical Issues
Sockets in nach0s
マイナーツールを使ってみる
Running workflows through galaxy bosc presentation
My mule esb first http flow
Ruby version manager
Ad

Similar to Java ppt (20)

DOCX
Servlet
PPTX
Javax.servlet,http packages
PPTX
Servlets
PPTX
JAVA SERVLETS acts as a middle layer between a request coming from a web brow...
PPTX
UNIT-3 Servlet
PPTX
Java servlets
PPT
Chap4 4 1
PPT
Java servlets
PPT
Servlet ppt by vikas jagtap
PPTX
Java servlets
PPTX
servlets sessions and cookies, jdbc connectivity
PPTX
servlet in java
PPT
PPT
S E R V L E T S
PDF
SERVER SIDE PROGRAMMING
PPTX
J2ee servlet
PPTX
SERVIET
PDF
Introduction to Servlets
PPTX
Wt unit 3
PPTX
Servlets-UNIT3and introduction to servlet
Servlet
Javax.servlet,http packages
Servlets
JAVA SERVLETS acts as a middle layer between a request coming from a web brow...
UNIT-3 Servlet
Java servlets
Chap4 4 1
Java servlets
Servlet ppt by vikas jagtap
Java servlets
servlets sessions and cookies, jdbc connectivity
servlet in java
S E R V L E T S
SERVER SIDE PROGRAMMING
J2ee servlet
SERVIET
Introduction to Servlets
Wt unit 3
Servlets-UNIT3and introduction to servlet
Ad

More from renukarenuka9 (20)

PPTX
mobile computing
PPTX
PPTX
Compiler design
PPTX
Web programming
PPTX
Software engineering
PPTX
Software engineering
PPTX
Software engineering
PPTX
Bigdata
PPTX
Bigdata ppt
PPTX
PPTX
PPTX
operating system
PPTX
PPTX
OPERATING SYSTEM
PPTX
Data mining
PPTX
Computer network
PPTX
computer network
PPTX
operating system
PPTX
data mining
PPTX
COMPUTER NETWORK
mobile computing
Compiler design
Web programming
Software engineering
Software engineering
Software engineering
Bigdata
Bigdata ppt
operating system
OPERATING SYSTEM
Data mining
Computer network
computer network
operating system
data mining
COMPUTER NETWORK

Recently uploaded (20)

PDF
Sciences of Europe No 170 (2025)
PDF
The scientific heritage No 166 (166) (2025)
PDF
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...
PDF
Cosmic Outliers: Low-spin Halos Explain the Abundance, Compactness, and Redsh...
PDF
Placing the Near-Earth Object Impact Probability in Context
PPTX
The KM-GBF monitoring framework – status & key messages.pptx
PPTX
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
PPTX
2. Earth - The Living Planet earth and life
PPTX
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
PPT
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
PDF
lecture 2026 of Sjogren's syndrome l .pdf
PPTX
INTRODUCTION TO EVS | Concept of sustainability
PPTX
Introduction to Cardiovascular system_structure and functions-1
PPTX
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
PPTX
7. General Toxicologyfor clinical phrmacy.pptx
PPTX
Derivatives of integument scales, beaks, horns,.pptx
PDF
. Radiology Case Scenariosssssssssssssss
PPT
protein biochemistry.ppt for university classes
PPTX
neck nodes and dissection types and lymph nodes levels
PDF
Phytochemical Investigation of Miliusa longipes.pdf
Sciences of Europe No 170 (2025)
The scientific heritage No 166 (166) (2025)
IFIT3 RNA-binding activity primores influenza A viruz infection and translati...
Cosmic Outliers: Low-spin Halos Explain the Abundance, Compactness, and Redsh...
Placing the Near-Earth Object Impact Probability in Context
The KM-GBF monitoring framework – status & key messages.pptx
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
2. Earth - The Living Planet earth and life
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
lecture 2026 of Sjogren's syndrome l .pdf
INTRODUCTION TO EVS | Concept of sustainability
Introduction to Cardiovascular system_structure and functions-1
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
7. General Toxicologyfor clinical phrmacy.pptx
Derivatives of integument scales, beaks, horns,.pptx
. Radiology Case Scenariosssssssssssssss
protein biochemistry.ppt for university classes
neck nodes and dissection types and lymph nodes levels
Phytochemical Investigation of Miliusa longipes.pdf

Java ppt

  • 2. Defination:  servlet is a java class that extends the functionality of web server. Eg:  mail server servlet is a class that performs virus scan to attached files
  • 3. Benefits  only one copy of servlet is loaded into jvm.  each request begins a new thread to servlet process. ◙ save time ◙ response time increases ◙ it is scalable
  • 6. Servlet implementation:  servlet use class and interface from 2 package ◘ javax.servlet  It contains classes to support generic protocol ◘ javax.servlet.http  It extends classes in servlet package to add HTTP sapecific functionality.
  • 9. Servlet API : o Servlet interface o Genericservlet class o HTTPservletrequest interface o HTTPservletrequest interface o Cookie class o HTTPsession interrface o single threadmodel interface o servletexception class o unavailableexception class o servlettcontext interfave o serrvletconfig interrface
  • 10. Servlet interface:  Every servlet must implements the javax.servlet interface  It can implement in 2 ways: ◙ Directly implementing interface ◙ Extending any of 2 classes: ◙ javax.serrvlet.genricservlet ◙ javax.servlet.http.HTTPservlet
  • 11. Methods: ◘ Init() ◘ Service() ◘ Destroy() ◘ Getservletinfo() ◘ Getservletconfig()
  • 12. Service() syntax:  public abstract voidservice(servletrequest req, servletresponse res)throws servletException,IOException ◙ it is called whenever the request is made ◙it must be overridden in servlet ◙ it receives request via servletrequest and sends response via servlet response
  • 13. HTTP servlet  It is an abstract class that is used for developing HTTpservlets.  It dose not override the service() method.  It override doget() to handle GET requests and dopost()to handle POST requests
  • 15. Methods: o serrvice() o doget() o dopost() o dodelete() o dooption() o do put() o do trace()
  • 16. do get() or do post() o protected void doget(HTTPServletRequest req HTTPServletResponse res)throws servletException,IOException o protected void dopost(HTTP ServletRequest req,HTTPservletresponse res) throws servletException,IOException
  • 17. public class SessionServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { res.setContentType("text/html"); OutputStream out = res.getOutputStream(); PrintWriter pw = new PrintWriter(new OutputStreamWriter(out)); HttpSession session = req.getSession(false); if (session == null) { session=req.getSession(true); session.putValue ("VisitCount", "1"); } pw.println("<html><body><pre>"); pw.println("session.isNew()="+session.isNew()); pw.println("session.getCreationTime()="+ new java.util.Date( session.getCreationTime())); pw.println("session.getID()="+session.getId()); pw.println("session.getLastAccessedTime()=" + new java.util.Date(session.getLastAccessedTime())); String strCount = (String) session.getValue("VisitCount"); pw.println("No. of times visited = " + strCount); int count = Integer.parseInt(strCount); count++; session.putValue("VisitCount", Integer.toString(count)); pw.println ("</pre></body></html>"); pw.flush(); } }