I wanted to know wheater a session obj created in servlet can be used in a jsp. I want some parameter to be passed , i have use sendRedirect() and also forward of the requestdispatcher.
hai patel, u can use the servlet session object in jsp page. u use RequestDispatcher .In this u use forward() method It redirct the request to that JSP page .In that JSP page u call session.getValue() saradhi
hi all i am having the same problem. i am setting some attributes for a session object in my servlet and using RequestDispatcher.forward to a new jsp. i am not able to get the attribute values in my jsp. . when i say session.getAttribute(****) i am getting null, somebody please help me in this.
In your servlet, you must use the passed in request object to obtain 'the' session, not just any session. This might be the problem if you're not doing it.
Session ses = request.getSession(); ses.setAttribute("hello", "hello"); . . . Then you get the RequestDispatcher and forward RequestDispatcher rd = getRequestDispatcher("/somePage.jsp"); rd.forward(request, response); . . inside somePage.jsp, you should be able to access "hello" like you already know how to do.
i called ServletContext.getRequestDispatcher(**). but if i give the whole absolute path of the jsp page it is returning null. like RequestDispatcher rd = ServletContext.getRequestDispatcher("http://localhost:7001/checkmail.jsp") here rd will be null. but if i give relative path like "/checkmail.jsp" i will get the rd object but when i call rd.forward(**,**) the jsp page is not coming i used the HttpServletRequest.getRequestDispatcher() also. i am using Weblogic 6.0 application server. i cannot give relative path like "/checkmail.jsp" becoz the control will be returned from a servlet ie "http://localhost:7001/examplesWebApp/MainServlet" and it is taking "http://localhost:7001/examplesWebApp/checkmail.jsp" so i am not able to view the jsp page. the MainServlet is a FrontController for the application and all the html/jsp request will go through this servlet. so according to the data got from the backend i should send the objects to the jsp page as session attributes.
Post by:autobot
Then YOU must do the pig's work! Read this tiny ad. READ IT!
a bit of art, as a gift, that will fit in a stocking