Java Techies - Solution for All
Java Techies - Solution for All
response.sendRedirect(www.jspts.com);
RequestDisptacher interface.| Forward | Include |
|---|---|
| Used to forward a request to one Servlet to another Servlet.This method must be used when output is generated by second Servlet If PrintWriter object is accessed by the first servlet already, then exception is thrown by this method | This method is used to invoke one servlet from the
another servlet like the forward method. However,you can also include the output of first servlet with current servlet. The first servlet can make use of the PrintWriter Object even after calling the include method. |
| ServletContext sc=
this.getServletConfig.getServletContext(); RequestDispatcher rd = sc.getRequestDispatcher ("/SecondServlet"); rd.forward(response,request); |
ServletContext sc=
getServletContext(); RequestDispatcher rd = sc.getRequestDispatcher ("/SecondServlet"); rd.include(response,request); |
| ServletConfig | ServletContext |
|---|---|
| One Servlet Config Object per Servlet | One Servlet Context per Web-Application. |
| Use it to pass deploy the Information to Servlet e.g-( A DataBase name or EJB look up name). | Use it to access Web-application parameter (it has setAttribute/getAttribute method).ServletContext also configure in Deployment Descriptor. |
| Use it access the servletContext | Use it as a kind of application bulletin-board,where you can put up messages or use it to get the server information including the name version of container |
ServletConfig sc=this.getServletConfig(); |
ServletContext
sc=this.getServletConfig.; |
String a=sc.getInitParameter ("email"); |
String a=sc.getInitParameter ("Companyemail"); |
| Entry in web.xml:- <servlet> <servlet-name>LoginServlet</servlet-name> <sevlet-class>LoginServlet</sevlet-class> <init-param> <param-name>email</param-name> <param-value>abc@yahoo.com</param-value> </init-param> </servlet> | Entry in web.xml:- <web-apps> <context-param> <param-name>companyemail</param-name> <param-value>efg@rkgit.com</param-value> </context-param> </web-apps> |
| No setAttribute and getAttribute in ServletConfig. | ServletContext has setAttribute(String name,Object o)to set value during coding and getAttribute to reterive the set value. |
Explore the world of open-source software with Groovy Grails!
— Har Narayan (@har_narayan44) December 6, 2025
Check out their collection of amazing open-source projects and get inspired to contribute or start your own project!
Visit: https://t.co/LYNd8Cs3N7
#OpenSource #GroovyGrails #SoftwareDevelopment #Innovation"


