Servlet Request Interface

Click to rate this post!
[Total: 0 Average: 0]

Servlet Request Interface:

A challenge of ServletRequest is used to give the client request information to a servlet, for instance, content sort, content length, parameter names and qualities, header informations, attributes.

Servlet Request Interface Methods

Example of ServletRequest to display the name:

index.html

  1. <form action=”welcome”method=”get”>
  2. Enter your name<input type=”text”name=”name”><br>
  3. <input type=”submit”value=”login”>
  4. </form>

DemoServ.java

  1. importservlet.http.*;
  2. importservlet.*;
  3. importio.*;
  4. publicclass DemoServ extends HttpServlet{
  5. publicvoid doGet(HttpServletRequest req,HttpServletResponse res)
  6. throwsServletException,IOException
  7. {
  8. setContentType(“text/html”);
  9. PrintWriter pw=res.getWriter();
  10. String name=req.getParameter(“name”);//will return value
  11. println(“Welcome “+name);
  12. close();
  13. }}

RequestDispatcher:

A challenge of ServletRequest is used to give the client request information to a servlet, for instance, content sort, content length, parameter names and qualities, header informations, attributes.

Methods of RequestDispatcher interface:
  1. public void forward(ServletRequest request, ServletResponse response)throws ServletException, java.io.IOException.
  2. public void include(ServletRequest request, ServletResponse response)throws ServletException, java.io.IOException.

forward( ) method:

forward( ) methodInclude( ) method:include ( ) methodSyntax of getRequestDispatcher method:

  1. publicRequestDispatcher getRequestDispatcher(String resource);

Subscribe
to our newsletter

Drop Us A Query

Trending Courses
  • Microsoft Azure Architect Technologies(AZ-300) | ITGuru
    Microsoft Azure Architect Technologies(AZ-300)
  • Azure is a great Microsoft Cloud Computing platform in providing various cloud services through online. ITGuru Certified Azure Architect certification course gives you the practical knowledge on Azure Cloud platform through real-world use cases from live experts

  • ServiceNow Admin Training | ITGuru
    ServiceNow Admin Training
  • Getting knowledge of cloud platforms like ServiceNow is essential in today’s world for the smooth running of projects in cloud platform. Turn your dream to the reality of becoming the Certified ServiceNow Administrator through ServiceNow Administration online certification Course with practical examples by live industry experts through online at ITGuru with real-world use cases.

  • Workday Financials Training | ITGuru
    Workday Financials Training
  • knowing the basics on any platform like Workday is not enough to sustain the IT industry. Hence it is essential to go beyond on Workday basics like Workday Financials training which lets you know the application of Financials management in real -world use cases from ITGuru Live Experts in a practical way.

  • Workday Training
  • An organization is considered as the best one when it offers the best benefits to the employee. Moreover, the greater the employee benefits, the greater the contribution to the organization. ITGuru let you know the practical workday Human Resource Management(HRM) features with live examples by experts

  • Python Online Course | ITGuru
    Python Online Course
  • Turn your dream into reality by ITGuru live experts with real-world use cases through practical knowledge on python online course and become the certified associate in python programming and become a master in python programming

  • Python Programming | ITGuru
    Python Programming
  • Python is the trending programming language in the IT industry. Mastering in python programming gives you more value among the people in the IT industry. Hence start today to learn python programming online by live experts with real-time uses cases at ITGuru


100% Secure Payments. All major credit & debit cards accepted.

Call Now Button