Servlet Request Interface

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
  • Selenium with python
    Selenium with Python Training
  • As we know, that Selenium with Python Web Browser Selenium Automation is Gaining Popularity Day by Day. So many Frameworks and Tools Have arisen to get Services to Developers.

  • Deep learning course
    Deep Learning Course
  • Artificial Intelligence, Deep mastering (DL) is completely about, many levels of Representation and sort of abstraction. That guide to design a sense of Information like Images, sound and text format.

  • machine learning with python
    Machine Learning with Python Training
  • Over last few years, Big Data and analysis have come up, with Exponential and modified Direction of Business. That operate Python, emerged with a fast and strong Contender for going with Predictive Analysis.

  • Data science with R
    Data Science With R Training
  • Understanding and using Linear, non-linear regression Models and Classifying techniques for stats analysis. Hypothesis testing sample methods, to get business decisions.

  • data science with python
    Data Science with Python Training
  • Everyone starts Somewhere, first you learn basics of Every Scripting concept. Here you need complete Introduction to Data Science python libraries Concepts.

  • devops with azure
    Devops with Azure Training
  • As we Know Azure DevOps is a Bunch of Services, in guiding Developers. It contains CI/CD, pipelines, code Repositories, Visual Reporting Tools and more code management with version control.


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