This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Hi, I am having problem setting custom header in my response.I have tried using setHeader(),addHeader()...but i dont see the header in the response.Read some where that we can override setheader() in our response wrapper class.Can some one please tell me how to do that.
MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Rahul Birdie
Greenhorn
Joined: Oct 31, 2007
Posts: 5
posted
0
here is my servlet : public void doGet(HttpServletRequest request, HttpServletResponse response){ response.addHeader("name", "rahul"); response.setHeader("name", "rahul"); response.sendRedirect("/some.jsp");}
in my JSP : <% Enumeration e =request.getHeaderNames(); while(e.hasMoreElements()){ String header= String.valueOf(e.nextElement()); out.println("Header :" + e.nextElement()+ "<BR>"); out.println("Value : " + request.getHeader(header)); }%>
I am using livehttp header too to check the header.Output from live http
GET /StatusReturn/StatusFilterCode/WebContent/WEB-INF/jsp/final.jsp HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.8) Gecko/20071008 Firefox/2.0.0.8 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-securid Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cookie: JSESSIONID=54411B48ED5F49AD57DE911CD31A839A
HTTP/1.x 200 OK Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=4BCAE7B35828BE3426D0EAA075AE4B0C; Path=/ Content-Type: text/html;charset=ISO-8859-1 Content-Length: 273 Date: Wed, 31 Oct 2007 23:35:24 GMT [ October 31, 2007: Message edited by: Rahul Birdie ]
If you're doing a sendRedirect, you're asking the browser to make another request (to the JSP). Once the browser makes that request, the response header of the previous request are lost.
And in any case, request headers and response headers are different, so the code wouldn't work no matter what.
I am trying to create a test env. for which i need to set an error status say 403...but i am not able to do it...i have tried setstatus(403) and the setHeader(SC_ , message) but i am not getting the status in the jsp.I am using only one jsp page.
i have looked at the interface but setheader,addheader,setstatus,senderror are the methods i can use and i have tried all of them.I have used filters too but still nothin.In DD i even have specified <error> tags.I still cant figure out what to do.....