on 01-27-2009 1:03 PM
Hi SAP EP Gurus,
I want to use response.setStatus() mehtod in jspdynpage but it is not working as expected. I am able to use other methods of response object like response.write().
As per my knowledge if i set response.setStatus(200) is should send error to client but it is not seding error.
It is working as same for both response.setStatus(200) and response.setStatus(500).
Is there any special way to use response.setStatus() in portal? It is working as expected in normal jsp application.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for reply!! But I am not able to use in EP scenario. These are working fine in normal JSP application.
I imported import com.sapportals.portal.prt.component.* package and used foloowing code.
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentResponse resp = (IPortalComponentResponse) this.getResponse();
resp.setStatus(500);
but setting 500 and 200 both are giving same result. I am expecting an error message in case of 500.
Hi,
I think you have to use the HttpServletResponse object instead of the IPortalComponentResponse object.
Typically you get the IPortalComponentResponse and IPortalComponentRequest objects in your JSP Dynpage (btw also in the Abstract Portal Component).
Then you can get the HttpServletResponse object by the following code:
HttpServletResponse servletResponse = request.getServletResponse(true); //suppose request is a IPortalComponentRequest
servletResponse.setStatus(500); //should work now...
I tried but had no luck. Below is my JSPDYNPAGE code...
<%@ page import="javax.servlet.http.HttpServletResponse" %>
<%@ page import="com.sapportals.portal.prt.component.IPortalComponentRequest,com.sapportals.portal.prt.component.IPortalComponentResponse"%>
<HTML>
<head>
</head>
<body>
<%
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
HttpServletResponse servletResponse = request.getServletResponse(true);esss
servletResponse.setStatus(500);
%>
</body>
</HTML>
It is not working showing portal run time error
You should look into the log file for analyzing the error, but anyway, I think there is a problem when you retrieve the request object. Try this code instead:
<%@ page import = "com.sapportals.portal.prt.runtime.PortalRuntime" %>
<%@ page import = "com.sapportals.portal.prt.component.IPortalComponentRequest" %>
<%@ page import = "javax.servlet.http.HttpServletResponse" %>
<%
IPortalComponentRequest currentRequest =(IPortalComponentRequest)pageContext.getAttribute(javax.servlet.jsp.PageContext.REQUEST);
HttpServletResponse servletResponse = currentRequest.getServletResponse(true);
servletResponse.setStatus(500);
%>
If the servlet.jar is in your class path this code will work.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.