RequestDispatcher exception?

Hi,
Following sample code trying to forward a jsp page and pass a parameter to the next page
String t = "test";
request.setAttribute("t",t);
try{
RequestDispatcher aDispatcher = request.getRequestDispatcher("UnitScr.jsp");
aDispatcher.forward(request, response);
}catch(Exception ex){
ex.printStackTrace();
But receive following runtime exception. Please let me know if i missed something
java.lang.ClassCastException: oracle.jsp.provider.JspUniversalHttpRequest
void org.apache.tomcat.facade.RequestDispatcherImpl.doForward(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
RequestDispatcherImpl.java:172

Hi,
Following sample code trying to forward a jsp page and pass a parameter to the next page
String t = "test";
request.setAttribute("t",t);
try{
RequestDispatcher aDispatcher = request.getRequestDispatcher("UnitScr.jsp");
aDispatcher.forward(request, response);
}catch(Exception ex){
ex.printStackTrace();
But receive following runtime exception. Please let me know if i missed something
java.lang.ClassCastException: oracle.jsp.provider.JspUniversalHttpRequest
void org.apache.tomcat.facade.RequestDispatcherImpl.doForward(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
RequestDispatcherImpl.java:172

Similar Messages

  • [Help] Weblogic throws exception under load testing

    Hello All,
    I have developed an application using struts 1.1 framework and deployed
    it on weblogic 8.1. The application works fine. But when we load test
    the application, weblogic throws an exception. I am not able to
    understand why is weblogic throwing this exception. The exception
    doesn't originate from my code
    I am using struts 1.1 on BEA weblogic 8.1 on HP-UX 11i.
    Please help me ... I will be very gratefull for your help.
    Here is the stack trace :
    <Jan 15, 2004 10:02:28 PM IST> <Error> <HTTP> <BEA-101020>
    <[ServletContext(id=28318025,name=testWebApp,context-path=/testWebApp)]
    Servlet failed with Exception java.lang.NullPointerException
    at
    weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(Se
    rvle
    tStubImpl.java:1053)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
    java
    :387)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
    java
    :305)
    at
    weblogic.servlet.internal.RequestDispatcherImpl$ForwardAction.run(Reques
    tDis
    patcherImpl.java:382)
    at
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSu
    bjec
    t.java:317)
    at
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118
    at
    weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatche
    rImp
    l.java:286)
    at
    org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.jav
    a:10
    69)
    at
    org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProc
    esso
    r.java:274)
    at
    org.apache.struts.action.RequestProcessor.processForwardConfig(RequestPr
    oces
    sor.java:455)
    at
    org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(Tiles
    Requ
    estProcessor.java:320)
    at
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
    279)
    at
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(Se
    rvle
    tStubImpl.java:1053)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
    java
    :387)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
    java
    :305)
    at
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.r
    un(W
    ebAppServletContext.java:6310)
    at
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSu
    bjec
    t.java:317)
    at
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118
    at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServl
    etCo
    ntext.java:3622)
    at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.
    java
    :2569)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    Regards,
    Abhishek.

    Hello All,
    I have developed an application using struts 1.1 framework and deployed
    it on weblogic 8.1. The application works fine. But when we load test
    the application, weblogic throws an exception. I am not able to
    understand why is weblogic throwing this exception. The exception
    doesn't originate from my code
    I am using struts 1.1 on BEA weblogic 8.1 on HP-UX 11i.
    Please help me ... I will be very gratefull for your help.
    Here is the stack trace :
    <Jan 15, 2004 10:02:28 PM IST> <Error> <HTTP> <BEA-101020>
    <[ServletContext(id=28318025,name=testWebApp,context-path=/testWebApp)]
    Servlet failed with Exception java.lang.NullPointerException
    at
    weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(Se
    rvle
    tStubImpl.java:1053)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
    java
    :387)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
    java
    :305)
    at
    weblogic.servlet.internal.RequestDispatcherImpl$ForwardAction.run(Reques
    tDis
    patcherImpl.java:382)
    at
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSu
    bjec
    t.java:317)
    at
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118
    at
    weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatche
    rImp
    l.java:286)
    at
    org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.jav
    a:10
    69)
    at
    org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProc
    esso
    r.java:274)
    at
    org.apache.struts.action.RequestProcessor.processForwardConfig(RequestPr
    oces
    sor.java:455)
    at
    org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(Tiles
    Requ
    estProcessor.java:320)
    at
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
    279)
    at
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(Se
    rvle
    tStubImpl.java:1053)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
    java
    :387)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
    java
    :305)
    at
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.r
    un(W
    ebAppServletContext.java:6310)
    at
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSu
    bjec
    t.java:317)
    at
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118
    at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServl
    etCo
    ntext.java:3622)
    at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.
    java
    :2569)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    Regards,
    Abhishek.

  • Java lang null pointer exception

    Hi
    I am trying to retrieve data from db and display in jsp.i am getting null pointer exception.connecting to db code is all fine .
    i am using it for the other pages also
    below is my code
    package updates;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.RequestDispatcher;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import Database.ConnectionPoolingPacs;
    import java.sql.Blob;
    public class EditBug extends HttpServlet {
        Connection connect=null;
        Statement stmt=null;
        ResultSet rs=null;
        ConnectionPoolingPacs Con=null;
        String BUGTITLE="";
        String SEVERITY ="";
        String BUG_ID="";
        String PROBABILITY="";
        String AUTHOR="";
        Blob  BUGDESCRIPTION1,ASSIGNEECOMMENTS1,CLOSINGCOMMENTS1=null;
        RequestDispatcher dispatcher=null;
        String STATUS,ASSIGNEDTO,CLOSEDBY=null;
        String IDENTIFIEDON,ASSIGNEDON,CLOSEDON=null;
        String BUGDESCRIPTION,ASSIGNEECOMMENTS,CLOSINGCOMMENTS=null;
        @Override
        public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
         response.setContentType("text/html");
         BUG_ID=request.getParameter("bugID");
                  try
                  Con=new ConnectionPoolingPacs();
                  connect=Con.getConnection();
                  stmt=connect.createStatement();
                  String QueryStringTest="Select * from bugdetails where Bug_Id ='"+ BUG_ID+"' ";
                  rs=stmt.executeQuery(QueryStringTest);
                  while (rs.next())
                    BUG_ID=rs.getString("Bug_ID");
                    BUGTITLE= rs.getString("Bug_Title") ;
                    BUGDESCRIPTION1=rs.getBlob("Bug_Description1");
                    AUTHOR=rs.getString("Bug_Author");
                    SEVERITY=rs.getString("Bug_Severity");
                    PROBABILITY=rs.getString("Bug_Probability");
                    STATUS=rs.getString("Bug_Status");
                    IDENTIFIEDON=rs.getString("Bug_IdentifiedOn");
                    ASSIGNEDON=rs.getString("Bug_assignedOn");
                    ASSIGNEDTO=rs.getString("Bug_AssignedTo");
                    ASSIGNEECOMMENTS1=rs.getBlob("AssigneeComments");
                    CLOSEDON=rs.getString("Bug_ClosedOn");
                    CLOSEDBY=rs.getString("Bug_ClosedBy");
                   CLOSINGCOMMENTS1=rs.getBlob("ClosingComments");
                    request.setAttribute("id",BUG_ID);
                    request.setAttribute ("title",BUGTITLE);
                    request.setAttribute ("author",AUTHOR);
                    request.setAttribute ("severity",SEVERITY);
                    request.setAttribute ("probability",PROBABILITY);
                    request.setAttribute ("status",STATUS);
                    request.setAttribute ("identifiedon",IDENTIFIEDON);
                    if ((ASSIGNEDON).equals("1001-01-01"))
                        ASSIGNEDON="";
                    request.setAttribute ("assignedon", ASSIGNEDON);
                    request.setAttribute ("assignedto", ASSIGNEDTO);
                     if ((CLOSEDON).equals("1001-01-01"))
                        CLOSEDON="";
                    request.setAttribute ("closedon", CLOSEDON);
                    request.setAttribute ("closedby", CLOSEDBY);
                    byte[] buffer1 = BUGDESCRIPTION1.getBytes(1, (int) BUGDESCRIPTION1.length());
                     BUGDESCRIPTION  = new String(buffer1);
                     byte[] buffer2 = ASSIGNEECOMMENTS1.getBytes(1, (int) ASSIGNEECOMMENTS1.length());
                    ASSIGNEECOMMENTS  = new String(buffer2);
                     byte[] buffer3 = CLOSINGCOMMENTS1.getBytes(1, (int)  CLOSINGCOMMENTS1.length());
                    CLOSINGCOMMENTS  = new String(buffer3);
                     request.setAttribute ("description",BUGDESCRIPTION);
                    if(ASSIGNEECOMMENTS!=null)
                     request.setAttribute ("assignecomments",ASSIGNEECOMMENTS);
                     if(CLOSINGCOMMENTS!=null)
                     request.setAttribute ("closingcomments", CLOSINGCOMMENTS);
                    stmt.close();
                    rs.close();
          catch(Exception e){System.out.println("Exception  ;"+e);}
              dispatcher = request.getRequestDispatcher("/EditBug.jsp");
              dispatcher.forward(request, response);
        }I have set 1001-01-01 as the default date.

    This is the exception which i am getting
    Aug 12, 2009 2:24:18 PM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet EditBug threw exception
    java.lang.NullPointerException
    at org.apache.jsp.EditBug_jsp._jspService(EditBug_jsp.java:703)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at updates.EditBug.doPost(EditBug.java:124)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
    and that line which its indicating as error is
    dispatcher.forward(request, response);
    Edited by: garlapati on Aug 12, 2009 8:55 AM

  • Class cast exception in jsp plz help

    i have written a jsp where i displayed a text box with value given by user inside it
    when the user enters some other value in text box and clicks on update button then i forwarded reqeust to servlet which will some data base work
    servlet will forward again to the same jsp with the new value in text box.
    but i am getting CLASS CAST EXCEPTION when servlet is forwarding reqeust to same JSP
    help me what to do ........
    thanking you in advance ..cheers

    display cart.jsp file:
    <%@ page import="java.util.*,org.*" %>
    <html>
    <body>
    <%
    Vector cartupdate = (Vector)session.getAttribute("cartlist");
    for (int i = 0; i < cartupdate.size(); i++) {
    CartListBean clb = (CartListBean)cartupdate.elementAt(i);
    %>
    <form name="itemslist<%=i%>" action="updateCart" method="post">
    <input type="hidden" name="itemcode" value="<%=clb.getItemCode()%>">
         <input type="hidden" name="itemname" value="<%= clb.getItemName()%>">
    <input type="hidden" name="price" value="<%= clb.getPrice()%>">
    <%= clb.getItemName() %>
    <input type="text" name="qty" value="<%=clb.getQuantity()%>">
    <input type="submit" name="<%=clb.getItemCode()%>" value="update">
    </form>
    <br>
    <%
    %>
    <form name="tobuy" action="buysrv" method="post">
    <input type="submit" name="buy" value="BUY">
    </form>
    </body>
    </html>
    updatecart servlet code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import org.*;
    import java.sql.*;
    import java.util.*;
    public class UpdateCart extends HttpServlet
    public void service(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
    HttpSession session=request.getSession(false);
    Vector cartupdate = (Vector)session.getAttribute("cartlist");
    for (int i = 0; i < cartupdate.size(); i++) {
    org.CartListBean cart = (org.CartListBean)cartupdate.elementAt(i);
    if((cart.getItemCode()).equals(request.getParameter("itemcode")))
    org.CartListBean clb=new org.CartListBean();
    clb.setItemCode(request.getParameter("itemcode"));
         clb.setQuantity(request.getParameter("qty"));
         clb.setItemName(request.getParameter("itemname"));
    clb.setPrice(request.getParameter("price"));
    cartupdate.setElementAt(clb,i);
    session.setAttribute("cartlist",cart);
    ServletContext application=getServletContext();
    System.out.println("got finished");
              RequestDispatcher rd=application.getRequestDispatcher("/displaycart.jsp");
                   rd.forward(request,response);
    Message was edited by:
    143java

  • Exception while excel processing after upload using commons file upload

    Hi all,
    I am experiencing problem while creating a workbook after getting the input stream from the uploaded file. its not going catch block instead it is going to finally and giving null pointer exeption in finally as one variable in finally is not defined. the variable is defined in try as well as catch but during run time the variable is not getting assigned any value also. I'll put the code over here. please help me with a solution
    import org.w3c.dom.* ;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import jxl.*;
    import org.apache.commons.fileupload.*;
    import org.apache.commons.fileupload.disk.*;
    import org.apache.commons.fileupload.servlet.*;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    public class CescoreUploadServlet extends baseHttpServlet
         private DataSource cesDS = null;
         public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
              doPost(req, res);
         public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
              String targetPage = null;
              File f = null;
              System.out.println("Upload Controller");
              HttpSession session = req.getSession(true);
              try
                   if(cesDS == null){
                        cesDS = new JNDIDataSource(getServletContext().getInitParameter(Constants.DATA_SOURCE_NAME));
                   CesRepository cRep = new CesRepository(cesDS);
                   if (session.getAttribute("DataContainerInfo") == null) {
                        System.out.println("Initializing DataContainerInfo");
                        DataContainer DataContainer = new DataContainer();
                        cRep.setInitialParameters(DataContainer);
                        session.setAttribute("DataContainerInfo",DataContainer);
                   else System.out.println("DataContainerInfo is available");
                   UserInfo userInfo = null;               
                   String login_id = req.getRemoteUser();
                   if(session.getAttribute("UserID") != null) login_id = (String)session.getAttribute("UserID");
                   if(session.getAttribute("userProfile") == null ) session.setAttribute("userProfile", cRep.getUserInfo(login_id));
                   userInfo = (UserInfo)session.getAttribute("userProfile");
                   System.out.println("<<<<<< userInfo contains : "+userInfo.getHrID()+" >>>>>>");
                   String projIdValue = null;
                   String msg = null;
                   boolean isMultipart = FileUpload.isMultipartContent(req);
                   if(isMultipart){
                        System.out.println("is MultiPart");
                        DiskFileUpload upload = new DiskFileUpload();
                        List fileList = upload.parseRequest(req);
                        InputStream uploadedFileStream = null;
                        String uploadedFileName = null;
                        ArrayList impArray = new ArrayList();
                        Iterator iter = fileList.iterator();
                        while (iter.hasNext()) {
                             System.out.println("inside while");
                             FileItem item = (FileItem) iter.next();
                             if (!item.isFormField()) {
                                  System.out.println("item is not form field");
                                  if (item.getSize() < 1)
                                       throw new Exception("No file was uploaded");
                                  else
                                       uploadedFileName = item.getName();
                                       System.out.println("uploaded file name "+uploadedFileName);
                                       System.out.println("uploaded file size is "+item.getSize());
                                       uploadedFileStream = item.getInputStream();
                                       System.out.println("uploaded input stream available size is "+uploadedFileStream.available());
                             else
                                  System.out.println("item is form field");
                                  String key     = item.getFieldName();
                                  String value = item.getString();
                                  System.out.println("key is"+key);
                                  System.out.println("value is"+value);
                                  if(key.equals("projectId2")){
                                       projIdValue = value;
                        System.out.println("outside while");
                        POIFSFileSystem fs = new POIFSFileSystem(uploadedFileStream);
                        System.out.println("got POIFSFileSystem");//this is been printed in logs
                        HSSFWorkbook wb = new HSSFWorkbook(fs);//it is breaking over here
                        System.out.println("got HSSFWorkbook");//this is not been printed in logs
                        HSSFSheet sheet = wb.getSheetAt(0);
                        System.out.println("got HSSFSheet");
                        Iterator rows = sheet.rowIterator();
                        if(rows.hasNext()){
                        while( rows.hasNext() ) {
                             System.out.println("rows iteration");
                             HSSFRow row = (HSSFRow) rows.next();
                             Iterator cells = row.cellIterator();
                             while( cells.hasNext() ) {
                                  System.out.println("cell iteration");
                                  HSSFCell cell = (HSSFCell) cells.next();
                                  HashMap hm = new HashMap();//if everything is fine i'll use this hashmap to store values
                             System.out.println("CES UPLOAD.SERVLET. After adding");
                             msg = "Attendees have been added successfully";
                             req.setAttribute("msgText", msg);
                             targetPage = "/ces_disp.jsp";
                        else
                             throw new Exception("The Excel Sheet Uploaded has no entries. Please check and try again");
                   else{
                        throw new Exception("The Form is not Multipart");
              catch (Exception e)
                   System.out.println("CES UPLOAD.SERVLET.EXCEPTION ::: Exception");
                   targetPage = "/ces_disp.jsp";
                   if(e != null) req.setAttribute("msgText", e.getMessage());
                   else req.setAttribute(Constants.EXCEPTION_ATTR_NAME, new Exception("Unknown Exception"));
                   e.printStackTrace();
              finally{
                   System.out.println("CES UPLOAD.SERVLET. ::: Finally");
                   ServletContext stx = getServletConfig().getServletContext();
                   RequestDispatcher dispatcher = sCx.getRequestDispatcher(targetPage);
                   dispatcher.forward(req, res);
    Message was edited by: Noufal
    Noufal_k
    Message was edited by:
    Noufal_k

    import org.w3c.dom.* ;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import jxl.*;
    import org.apache.commons.fileupload.*;
    import org.apache.commons.fileupload.disk.*;
    import org.apache.commons.fileupload.servlet.*;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    public class CescoreUploadServlet extends baseHttpServlet
    private DataSource cesDS = null;
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    doPost(req, res);
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    //including only relevant code
    String targetPage = null;
    System.out.println("Upload Controller");
    HttpSession session = req.getSession(true);
    try
    String projIdValue = null;
    String msg = null;
    boolean isMultipart = FileUpload.isMultipartContent(req);
    if(isMultipart){
    System.out.println("is MultiPart");
    DiskFileUpload upload = new DiskFileUpload();
    List fileList = upload.parseRequest(req);
    InputStream uploadedFileStream = null;
    String uploadedFileName = null;
    Iterator iter = fileList.iterator();
    while (iter.hasNext()) {
    System.out.println("inside while");
    FileItem item = (FileItem) iter.next();
    if (!item.isFormField()) {
    System.out.println("item is not form field");
    if (item.getSize() < 1)
    throw new Exception("No file was uploaded");
    else
    uploadedFileName = item.getName();
    System.out.println("uploaded file name "+uploadedFileName);//printing  c:/excelsheets/fileToUpload.xls
    System.out.println("uploaded file size is "+item.getSize());//printing size is 15872
    uploadedFileStream = item.getInputStream();
    System.out.println("uploaded input stream available size is "+uploadedFileStream.available());//printing available input stream size is 15872
    else
    System.out.println("item is form field");
    String key = item.getFieldName();
    String value = item.getString();
    System.out.println("key is"+key);
    System.out.println("value is"+value);
    if(key.equals("projectId2")){
    projIdValue = value;
    System.out.println("outside while");
    POIFSFileSystem fs = new POIFSFileSystem(uploadedFileStream);
    System.out.println("got POIFSFileSystem");//this is been printed in logs
    HSSFWorkbook wb = new HSSFWorkbook(fs);//it is breaking over here
    System.out.println("got HSSFWorkbook");//this is not been printed in logs
    HSSFSheet sheet = wb.getSheetAt(0);
    System.out.println("got HSSFSheet");
    Iterator rows = sheet.rowIterator();
    if(rows.hasNext()){
    while( rows.hasNext() ) {
    System.out.println("rows iteration");
    HSSFRow row = (HSSFRow) rows.next();
    Iterator cells = row.cellIterator();
    while( cells.hasNext() ) {
    System.out.println("cell iteration");
    HSSFCell cell = (HSSFCell) cells.next();
    HashMap hm = new HashMap();//if everything is fine i'll use this hashmap to store values
    System.out.println("CES UPLOAD.SERVLET. After adding");
    msg = "Attendees have been added successfully";
    req.setAttribute("msgText", msg);
    targetPage = "/ces_disp.jsp";
    else
    throw new Exception("The Excel Sheet Uploaded has no entries. Please check and try again");
    else{
    throw new Exception("The Form is not Multipart");
    catch (Exception e)
    System.out.println("CES UPLOAD.SERVLET.EXCEPTION ::: Exception");
    targetPage = "/ces_disp.jsp";
    if(e != null) req.setAttribute("msgText", e.getMessage());
    else req.setAttribute(Constants.EXCEPTION_ATTR_NAME, new Exception("Unknown Exception"));
    e.printStackTrace();
    finally{
    System.out.println("CES UPLOAD.SERVLET. ::: Finally");
    ServletContext stx = getServletConfig().getServletContext();
    RequestDispatcher dispatcher = stx.getRequestDispatcher(targetPage);//throwing null pointer exception for this line
    dispatcher.forward(req, res);
    }

  • Error While using RequestDispatcher.forward

    Hi All,
    I am getting an error while i am forwarding a request from a controller servlet to a JSP in WAS 3.5.
    i am using the following code:
    String url = "../gede/globalservices/SCSLogin.jsp";
    RequestDispatcher rd = getServletConfig().getServletContext().getRequestDispatcher(url);
    rd.forward(request, response);
    The error i get is :
    Error 404
    An error has occured while processing request:http://teamsite-cwc-review.indsys.ge.com/cwc/servlet/com.geindsys.gede.globalservices.SCSControllerServlet
    Message: [JSP 1.0 Processor] reported an error
    i was able to get the same while using response.SendRedirect(url);
    Please help..
    Thanks in Advance..
    Regards,
    Ravi.

    Looks like your JSP is throwing an exception. Check the logs in your server to find the details about it. (Was there an XML question here? I couldn't see one.)

  • Problem with forward using RequestDispatcher

    Dear All
    Below is my code, which trying to use the RequestDispatcher.forward to go from a Servlet to a .jsp page.
    and use
    getServletContext().setAttribute("SvBio",vBio);
    to set an attribute
    It compiles finely but stuck at the forward request to the jsp page and through an exception which is given below.
    BUT on removing this statement
    getServletContext().setAttribute("SvBio",vBio);
    from my doget method , it works and forwrds to the next page
    please help me identifying the problem
    Thanks
    NAV
    ////Part of CODE////////////////
    Vector vBio;
    public void init()
    // vector vBio initialize in init()
    public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
    getServletContext().setAttribute("SvBio",vBio);
    if(param1 == bio)
    gotoPage("/jsp_pages/bio_gp.jsp", request, response);
    private void gotoPage(String address, HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(address);
    if(dispatcher !=null)
    dispatcher.forward(request, response);
    ///exception//////////////////
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
         at nav.gotoPage(nav.java:363)
         at nav.doGet(nav.java:319)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
         at java.lang.Thread.run(Thread.java:595)
    root cause
    java.lang.NullPointerException
         at org.apache.jsp.bio_gp_jsp._jspService(bio_gp_jsp.java:59)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
         at nav.gotoPage(nav.java:363)
         at nav.doGet(nav.java:319)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
         at java.lang.Thread.run(Thread.java:595)
    Apache Tomcat/4.1.29-LE-jdk14

    Thanks evnafets
    I find out null pointer assignment in jsp page where forward request was heading.
    There is one more question, if you help me a better understanding the issue
    I have a HTML page invokes the servlet by passing value of parameter, Servlet do some procesing and forward to JSP page depending on the incoming parameter,
    Can JSP page invoke the same servlet by passing some other parameter?
    I tried doing this, but it returns an empty page and didnt went back to servlet.
    HTML Page ---->Servlet--------> JSP page ---------> Servlet
    I think Forward method shift the control from the Servlet to JSP page and now its the responsibility of the jsp page to deliver the response to the client.
    Am i getting the empty page on invoking the servlet from the JSP page because I have not deliver the response to the client?
    ///the code of the JSP page is as fallows///
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>NAVTITLE</title>
    </head>
    <body link="#0000FF" vlink="#0000FF" alink="#0000FF">
    <td height="340" width="977">
    <p align="center"><font size="8" color="#001000"><b>biomolecular group           page</b></font></p>
    <%@page import="java.util.Vector"%>          
    <% Vector vBiopt = (Vector)getServletContext().getAttribute("SvBio");     
    out.println("\nThe size of vBio is ::"+vBiopt.size());
    int n = vBiopt.size();
    %>
    <p>This is the dynamic page generated for the biomolecular group</p>
    <%
    for(int k=0;k<n;k++)
    String href1 ="http://localhost:8080/nav/nav2?param2=";
    String item = (String)vBiopt.elementAt(k);
    out.println("<p><a href= \"" + href1 + k + "\">" + item + "</a></p>");
    %>
    </body>
    </html>

  • Nested request dispatches when using RequestDispatcher in a Button action

    Hi all,
    I am new to JSF so I am probably missing something very simple, please help:
    The test case is simple: I created one visual web page with one button and one normal JSP file(named test.jsp) using Netbeans 5.5 with visual web pack on Sun Application Server 9 PE. The code action for the button is as follows:
    public String button1_action() throws Exception
            ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
            HttpServletRequest request = (HttpServletRequest) context.getRequest();
            HttpServletResponse response = (HttpServletResponse) context.getResponse();
            RequestDispatcher dispatcher = request.getRequestDispatcher("test.jsp");
            dispatcher.forward(request,response);
            return null;
        }Once the JSF page is loaded and the button is clicked, this exception occurs:
    ApplicationDispatcher[WebApplication1] Servlet.service() for servlet Faces Servlet threw exception
    javax.servlet.ServletException: WEB2651: Exceeded maximum depth for nested request dispatches: 20
    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:837)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:697)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:532)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:465)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:353)
    at webapplication1.Page1.button1_action(Page1.java:242)
    Can anyone provide any advice on how to resolve this issue?

    Hi Rachel,
    As per the Servlet2.3 Javadoc:
    The pathname must begin with a "/" and is interpreted as relative to the current context root.
    If you make that change and include the complete path, then it would work fine.
    Ex:
    If your context looks like http://my.company.com/webapp1/ and if you were to have your forwardPortlet.jsp in a directory like:
    webapp1
      |
      |-> htdocs
             |
             |-> forwardPortlet.jsp
    then, your code would look like;
    RequestDiscpatcher d = request.getRequestDispatcher("/htdocs/forwardPortlet.jsp");
    HTH,
    thanks,
    harsha

  • Illegal State Exception with Servlets

    Hi Friends,
    I am using RequestDispatcher to forwrd my request from one servlet to another
    Here's the code
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class TryServlet extends HttpServlet
    public void service(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url="jdbc:odbc:con";
    Connection con= DriverManager.getConnection(url,"scott","tiger");
    Statement stmt=con.createStatement();
    ResultSet rst=stmt.executeQuery("select * from Projects");
    response.setContentType("text/html");
    PrintWriter out=response.getWriter();
    while (rst.next())
    String firstname=rst.getString("PIN");
    String lastname=rst.getString("ProjectTitle");
    out.println("<p> Name:"+firstname+" "+lastname+"");
    con.close();
    RequestDispatcher rd=getServletContext().getNamedDispatcher("HelloServlet");
    rd.forward(request,response);
    return;
    catch(Exception e)
    e.printStackTrace();
    I m getting the error
    java.lang.IllegalStateException: Cannot forward after response has been committed
    i need to include the two rows of tables before i forwad the request to HelloServlet
    What needs to be done?
    thanx
    Pooja

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class TryServlet extends HttpServlet
    public void service(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url="jdbc:odbc:con";
    Connection con= DriverManager.getConnection(url,"scott","tiger");
    Statement stmt=con.createStatement();
    ResultSet rst=stmt.executeQuery("select * from Projects");
    response.setContentType("text/html");
    PrintWriter out=response.getWriter();
    while (rst.next())
    String firstname=rst.getString("PIN");
    String lastname=rst.getString("ProjectTitle");
    out.println("<p> Name:"+firstname+" "+lastname+"");
    con.close();
    RequestDispatcher rd=getServletContext().getNamedDispatcher("HelloServlet");
    rd.forward(request,response);
    return;
    catch(Exception e)
    e.printStackTrace();
    please explain your problem for more details???

  • Exceptions thrown after a jsp:include

    Hi all,
              At the beginning of my JSP, I can't use the JSP include directive because I
              need to do a specific include from another webapp servlet context. Thus I
              wrote my own include tag <mytag:include page="" context=""/> where I use
              RequestDispatcher.include().
              But then I am facing the following problem with this JSP :
              [myjsp.jsp]
              <mytaglib:include page="" context=""/>
              <mytaglib:stgElse/>
              if the second tag <mytaglib:stgElse> is throwing a JspException, and if I
              use the error handling system of the webapp :
              [web.xml]
              <error-page>
              <exception-type>javax.servlet.jsp.JspException</exception-type>
              <location>/web/en/pf/error.jsp</location>
              </error-page>
              I get : "java.lang.IllegalStateException: Cannot forward a response that is
              already committed"
              because it tries to do a forward after an include which needed a flush of
              the buffer previously, what means the response was already comitted.
              Thus the question is : how to handle exceptions coming after an include was
              done, that is to say after a flush of the buffer has already been committed
              Thanks for any help.
              Yann
              

    In the doc, it states:
    sendRedirect
    If the response has already been committed, this method throws an
    IllegalStateException. After using this method, the response should be
    considered to be committed and should not be written to.
    In other words, you must not do anything before or after with the response.
    Cameron Purdy, LiveWater
    "Lawrence Lourduraj" <[email protected]> wrote in message
    news:8ip9p4$r0g$[email protected]..
    >
    Friends,
    How do I do a redirect either through HttpServletResponse.sendRedirect ()or
    <jsp:forward /> in a JSP that does a <jsp:include /> at the top.
    I am getting a IllegalState exception.
    Thanks
    Regards
    Lawrence Lourduraj
    VocaLoca Inc.

  • RequestDispatcher -  What is the expected behaviour defined by the spec

    Hello,
    I just try to understand the servlet specification correctly.
    I don't understand what should happen when I try to access an not-existent resource by means of the RequestDispatcher.
    That's the way my source code looks:
    RequestDispatcher rd = servletRequest.getRequestDispatcher(jspName);
    try {
    if (rd != null) rd.include(origRQ, desc.getResponse());
    } catch (Exception e) { e.printStackTrace(); } I see following possibilities:
    1.
    The RequestDispatcher is not null and invoking the method include
    on the RequestDispatcher will lead to a 404 Http error.
    2.
    The RequestDispatcher is not null and invoking the method include
    or forward on the RequestDispatcher will lead to a ServletException (the
    root exception of this is a FileNotFoundException)
    3.
    The requestDispatcher is null
    I don't see anything about this in the servlet specification.
    Maybe I just don't find it. What should be the behaviour defined
    by the servlet spec.
    Any help appreciated.
    Many thanks in advance.

    Thanks for your answers.
    So this means this behaviour differs from servlet container to servlet container and it is not determined by the specification. I asked this
    question mainly, because I observed different behaviour for two different servlet container and I wanted to clarify which behaviour
    is the correct one.
    In ServletExec I got back a 404 error. In Iona's servlet engine I got
    back a ServletExecption (root cause is a FileNotFoundException).

  • Proper use of RequestDispatcher.forward()

    I have a servlet, and want to forward on to an error JSP page for
              exceptions. Is RequestDispatcher.forward() supposed to return to the
              source servlet when the target is finished?
              I am using a return to stop the source servlet when the target is
              finshed. Is this the correct behavior? Isn't this behavior very
              similar to to include(), or is the only difference that include() does
              not clear the source servlet's response buffer?
              TIA,
              Alex
              

    Alexander,
              The forward kindof has to return to the source servlet because that's
              where it's called from(unless it threw an exception). A servlet that
              performs a forward is meant to do preliminary processing of the request and
              allow another resource to generate the response. You are right in that it is
              basically an include that clears the buffer. If you want it to make a whole
              new request you should probably use a redirect.
              The weblogic docs help clarify things a bit(as well as the regular
              javadocs). http://www.weblogic.com/docs51/classdocs/API_servlet.html#129331
              Hope this helped.
              -jeremy
              Alexander Kowalyshyn <[email protected]> wrote in message
              news:[email protected]..
              > I have a servlet, and want to forward on to an error JSP page for
              > exceptions. Is RequestDispatcher.forward() supposed to return to the
              > source servlet when the target is finished?
              >
              > I am using a return to stop the source servlet when the target is
              > finshed. Is this the correct behavior? Isn't this behavior very
              > similar to to include(), or is the only difference that include() does
              > not clear the source servlet's response buffer?
              >
              > TIA,
              >
              > Alex
              >
              

  • Calling a html page deployed in weblogic server using RequestDispatcher

    Hi All,
    I want to call a HTML page from a java page using requestdispatcher. The whole application is deployed in Weblogic server.I have used the below syntax to call the page from any machine..
    ServletContext sc = getServletContext();
         RequestDispatcher rd = sc.getRequestDispatcher("http://172.25.40.148:7001/Filecomparetool/Result3.html");
         rd.forward(req, res);
    Im getting Null pointer exception...Plz help..Thanks in advance!

    Please use the CODE tags (see the CODE button above, or the formatting tips page, and not the BOLD button.
    Post the stack trace.
    Either getServletContext or getRequestDispatcher is returning null. Find out which, read the API to find out why.

  • RequestDispatcher error

              hi
              while using the the forward method in RequestDispatcher, i encounter the error below. it is complaining that it cant find the method "RequestDispatcherImpl.forward".
              as my machine has a few different JDKs, is there the possiblity of it using the wrong one? i have set my JAVA_HOME to JDK1.2.2 though.
              i have checked that my classpaths are set correctly as well.
              any help is much appreciated.
              thanx
              yunyee
              ********* Error Log **********
              Mon Nov 27 17:41:28 GMT+08:00 2000:<E> <ServletContext-General> Servlet failed with Exception
              java.lang.NoSuchMethodError
              at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:95)
              

    Hello,
              I suppose u should first download the j2eesdk1.2.2 , or simply download the jsdk (Java Servlet Development Kit) from developer connection in java.sun.com.
              In fact, your library for servlet may just support Servlets spec. 2.1, which does not contain the imple. of RequestDispatcher.
              Anthony
              yunyee wrote:
              > hi
              >
              > while using the the forward method in RequestDispatcher, i encounter the error below. it is complaining that it cant find the method "RequestDispatcherImpl.forward".
              >
              > as my machine has a few different JDKs, is there the possiblity of it using the wrong one? i have set my JAVA_HOME to JDK1.2.2 though.
              > i have checked that my classpaths are set correctly as well.
              >
              > any help is much appreciated.
              > thanx
              >
              > yunyee
              >
              > ********* Error Log **********
              > Mon Nov 27 17:41:28 GMT+08:00 2000:<E> <ServletContext-General> Servlet failed with Exception
              > java.lang.NoSuchMethodError
              > at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:95)
              Click here for Free Video!!
              http://www.gohip.com/free_video/
              [ctlai.vcf]
              

  • Character Encoding Problem RequestDispatcher

    Hi Friends;
    I have a servlet and I use
    RequestDispatcher dispatcher = request.getRequestDispatcher(page);
                   response.setContentType("text/html;charset=UTF-8");
                   request.setCharacterEncoding("UTF-8");
                   PrintWriter out = response.getWriter();
                   //request.setCharacterEncoding("utf-8");
                   try {
                        dispatcher.forward(request, response);
                   } catch (ServletException e) {
                        e.printStackTrace();
                   } catch (IOException e) {
                        e.printStackTrace();
    for forward page. But if i forward a page, this pages' encoding isnot working. But if i refresh page it works.
    How can i handle this encoding.
    Thanks replies

    Hi Eray,
    It really doesn't make any sense (exept in very specific, well, exceptional cases) to call setContentType and/or getWriter on the response object before doing a forward (neither does calling setCharacterEncoding on the request object usually makes sense);
    request.getRequestDispatcher(page).forward(request, response);
    should be sufficient. I assume you forward to a jsp page? In case you want to enforce the response encoding of the content of the jsp page to be UTF-8, you can use this page directive at the top of your jsp page:
    <%@ page contentType="text/html; charset=UTF-8" %>
    I don't know why it does work when you refresh the page, maybe your browser configuration is not correct (in IE: Page/View > Encoding > Auto-Select)?
    Kind regards,
    Sigiswald

Maybe you are looking for

  • ITunes not opening.  NO ERROR MESSAGE

    I cannot get iTunes to open. When I double click on it, the "hour glass" shows up, and I give it a minute or more, but the program does not open? I have the updated verision, but cannot get it to open. No error message when I try to open it...no prog

  • How do I view my purchases made with an iTunes gift card?

    i want to view what I purchased on iTunes gift card But I'm unable to find it. I can find my balance on the card, no problem. Here is why, because I made some purchases at the App Store but the cost of the purchases subtracted from the balance does n

  • Can I get a cable to connect my iPod to my iPad instead of to my laptop?

    Can I get a cable to connect my iPod to my iPad instead of to my laptop?

  • SocketTimeoutException

    hi all, i am using Tomcat server for my web applications. i hav deployed both midtier and webtier codes in correct and also i hav checked midtier (submitting request elements), its worked well alone.... But when i am sending a request from webtier to

  • Mail Account still active

    Hi All, By mistake i have deleted an account using the iDA without deactivating the mail for that user... the user is still receiving mails to his inbox.. how can i fix that? I need to deactivate his mail but i can't find the user anywhere since i de