Data transfer between Servlet and JSP?

Stop using Servlets in JSF. The servlet has apparently some functionality which you'd like to reuse somewhere else. Simply refactor it into a standalone and reuseable class/method which you in turn can just import/invoke in both the servlet class and the JSF managed bean.

I have a JSF/JSP page, a managed bean, and a separate file/class that extends HttpServlet with the doPost method. Stop using Servlets in JSF. The servlet has apparently some functionality which you'd like to reuse somewhere else.

Simply refactor it into a standalone and reuseable class/method which you in turn can just import/invoke in both the servlet class and the JSF managed bean. As to your actual problem: assuming that you actually meant "request attribute" when you said "request object", which seem to be unreachable in the JSF page, then this can have only two reasons: either the attribute name is wrong, or it is not the bean/pojo instance you expect it to be (which can happen if you create multiple instances).

If so, try this from inside an action method in your managed bean: FacesContext facesContext = FacesContext. GetCurrentInstance(); ExternalContext externalContext = facesContext. GetExternalContext(); HttpServletRequest request = (HttpServletRequest)externalContext.getRequest().

My apologies, the question was not clear. I have a JSP/JSL page with a managed bean associated with it. The page is kicked off by request.

GetRequestDispatcher("/faces/xxx. Jsp"). Forward(request, response); from another source.

I am asking for a way with JSTL, to retrieve the request (or an object in the request), and send it to the managed bean. Note: Assume the request key="chart" and the object=privateChart Assume the backing bean (a POJO) is "BeanA" and the method is "getChart" Currently using JSTL 1.2 – John K Oct 5 '10 at 19:42.

Assuming that you are using JSF, something very simple you could do from your managed bean is just to pass the data as an attribute in the request and then dispatch to the desired servlet: FacesContext context = FacesContext. GetCurrentInstance(); HttpServletRequest request = (HttpServletRequest) context. GetExternalContext().getRequest(); request.

SetAttribute("myData",myData); context. GetExternalContext(). Dispatch("/MyServlet"); context.

ResponseComplete(); In your servlet: protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String myData = (String)req. GetAttribute("myData"); //Do something with myData }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions