Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet Using httpservletresponse interface
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


ratna rathor
Using httpservletresponse interface
1 Answer(s)      2 years and 6 months ago
Posted in : JSP-Servlet


How do you use httpservletresponse interface?


Advertisement
View Answers

May 23, 2012 at 4:03 PM


Example:

package roseindia;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AddCookie extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
    Cookie langCookie = new Cookie("fruits", "Apple");
    response.addCookie(langCookie);
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<h2> Cookie added</h2>");
    out.println("</html>"); 
    }
}

Description: -addCookie() is one of the method of Httpservletresponse interface. This example shows how we are adding cookie to our HttpServletResponse.After executing your servlet, you can check your browser cookies to confirm that your cookie has been added or not.



Related Tutorials/Questions & Answers:
Using httpservletresponse interface
Using httpservletresponse interface  How do you use httpservletresponse interface?   Example: package roseindia; import... of Httpservletresponse interface. This example shows how
Various methods of httpservletresponse interface
Various methods of httpservletresponse interface  What are the various methods of httpservletresponse interface
Advertisements
Caching HttpServletResponse's content.
Caching HttpServletResponse's content.  I am trying to cache the response using Filter. I have extended HttpResponseWrapper. It has issues with flushing the streams. If you hit the service for the first time, it fetches the data
Httpservletresponse null pointer exception.
Httpservletresponse null pointer exception.  What is Httpservletresponse null pointer exception?   NullPointerException occurs when we try to implement an application without referencing the object and allocating
Multiple inheritance using interface - Java Beginners
Multiple inheritance using interface  Hi, I understand the concept & uses of an interface. But i dont know about the implementation of interface in real time. Because most of the interface examples are with one class
interface
interface  can we extend interface?   Hi Friend, Yes an interface can be extended by other interface like using extends keyword interface A{ } interface B extends A{ } For Example: interface IntefaceA { void
interface
is achieved by using the interface (by implementing more than one interface at a time...interface  what the use of interface?   An interface is one... variables.Any class can implement(inherit)the interface and make use
interface
interface   what is the use of marking interface
sendRedirect In JSP
sendRedirect In JSP          sendRedirect() method is a method of HttpServletResponse interface. When a client sends a request for a particular page
interface.
interface.  Write short note on interface.   Please visit the following link: Java Interface
interface
interface  will the interface implements a interface   Hi Friend, No. Interface can extends another interface but cannot implements it, because interface will not contain the implementation. Thanks
interface
interface   Hi I have interface in that interface 3 methods are there , after some days client said that,i want to add one more method in that interface ,so how can add 4 method so that the implemented class did not affect
INTERFACE
INTERFACE  how interface support multiple inheritance in java
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
interface
interface  What is marker interface ?? what is its use in java programming?? is this us in programming ??Explain is implementation with code
interface
interface  why do we need interface in java..if it`s usefull for to obtain multiple inheritance in the sense how it gonna be achieved...and i can...)...the y we need interface...THis is question often i heard from my developer
Interface
for Interface in java? and want to know why they used interface instead of multiple inheritance? Thanks in advance   An interface is one which has abstract... implement(inherit)the interface and make use of the methods(functions
Interface
Interface  I need to implement the interface without overriding its method and also don't use abstract class for this. How to do
interface
interface  What is the exact use of interface in real time scenario? some people says that interface provides multiple inheritance. Is it true...; Through interface, we can achieve the multiple inheritance. Java does
Interface
Interface  1.Create an interface names ShapeInterface that has two... class a.Rectangle that uses the interface b.Circle that uses the interface and abstract class   interface ShapeInterface{ int l=0,b=0; public
Interface
Interface  1.Create an interface names ShapeInterface that has two... class a.Rectangle that uses the interface b.Circle that uses the interface and abstract class   interface ShapeInterface{ int l=0,b=0; public
Interface
Interface  Declare an Interface called property containting a method compute price to compute &return the price.The inerface is to be implemented by follwaing two class (1)Bungalow&(2)Flat both the lasses have following
Diff between Runnable Interface and Thread class while using threads
Diff between Runnable Interface and Thread class while using threads  Diff between Runnable Interface and Thread class while using threads  ... to Runnable Interface. 3)Using Runnable Interface, you can run class several
Diff between Runnable Interface and Thread class while using threads
Diff between Runnable Interface and Thread class while using threads  Diff between Runnable Interface and Thread class while using threads  ... to Runnable Interface. 3)Using Runnable Interface, you can run class several
interface_querry
interface_querry  By using interface we have to implement all unimplemented methods into our class, even though we are not using all of methods, what is the alternative
Abstract and Interface
for using interface? Why we use interface instead of abstract? What..., etc.. 4)Java interface should be implemented using keyword 'implements'; A Java abstract class should be extended using keyword 'extends'. 5)An interface can
What is an interface?
What is an interface?  What is an interface
Can an Interface extend another Interface?
Can an Interface extend another Interface?   Hi, Can an Interface extend another Interface? thanks
Can an Interface implement another Interface?
Can an Interface implement another Interface?   Hi, Can an Interface implement another Interface? Thanks
ServletRequest interface
ServletRequest interface   What is new in ServletRequest interface
 

 

 

DMCA.com