cancel
Showing results for 
Search instead for 
Did you mean: 

Exception while using servlet RequestDispatcher

Former Member
0 Kudos

Hi,

I am forwarding my request from a dynpage which is running SAP portal to another servlet which is running in apache server on another machine. I use RequestDispatcher for this. but while executing iam getting this exception

<b>PortalRuntimeException: iView not found: http:.default</b>.

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

HttpServletRequest req = request.getServletRequest();

RequestDispatcher rd = req.getRequestDispatcher("http://c8048:8080/SSO/verify");

HttpServletResponse resp = request.getServletResponse(true);

rd.forward(req,resp);

Iam able to call the servlet directly from browser. Please help me

Accepted Solutions (0)

Answers (1)

Answers (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Sujesh,

with the code given (advise: use the "Code" button to mark code as code, makes it far more readable), this cannot work.

The RequestDispatcher can only dispatch to some servlet under the same servlet context (which is /irj for the portal), see http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletRequest.html#getRequestDispatcher... : "it cannot extend outside the current servlet context"

A workaround for you could be to redirect (but this happens on client side) using

portalComponentRequest.redirect(redirectURI);

Hope it helps

Detlev

PS: Please consider rewarding points on SDN for helpful answers. Thanks in advance!

Former Member
0 Kudos

Hi Sujesh,

Detlef is right, the Requestdispatcher works only in the current context. But you can first try to relove the new context and then call the RequestDispatcher.


ServletContext ctx = req.getServletContext();
ctx.getContext("....(Your Context)").getRequestDispatcher("...(Local Url under context)");

For Example:

ctx.getContext( "/irj/" ).getRequestDispatcher(
                "/portalapps/myTestApp/images/RTFM.gif")
                .forward( request, response );

Another approach is the following. Try this out:

HttpURLConnection urlConnection = (HttpURLConnection) (new URL("http://c8048:8080/SSO/verify")).openConnection();
urlConnection.connect();
InputStream inStream = urlConnection.getInputStream();
OutputStream outStream = resp.getOutputStream();
byte[] b = new byte[1];
while( inStream.read( b ) != -1 )
{
    outStream.write( b );
}
outStream.flush();
urlConnection.disconnect();

Regards,

Stefan

P.S. And as Detlef suggest: consider rewarding points for helpful answers.