Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

setting Http Request and Response from JSP/Servlet.

843838Oct 26 2006 — edited Nov 3 2006
i want to set http headers for a request and process the this header values and set the http response header.
i could find setHeader method for the response object but not for request
	public void doPost (HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException
	{
		String value=req.getHeader("MyName");
		resp.setHeader("YourName", "Devi");
		resp.setContentType("text/html");
		PrintWriter out=resp.getWriter();
		out.println("Header Value = " + value);	
	}
what i'm planning to do is...pls correct me if i'm wrong.
i have a jsp page this will set the http request header named "MyName".
Now when i submit this page this will call the servlet shown above.
this servlet will retrive this header value and set the response header and
writes back to the client.
from the client i want to take the response header value.

hope u understood what i mean though the way i did doesnot make sense.
i'm new to web applications and j2ee.

example codes will be really appreciated
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 1 2006
Added on Oct 26 2006
12 comments
1,238 views