I.- SETEAR EN SESION:
A.- JSP: request.getSession().setAttribute("miVariable",valor);
B.- JSF: FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("miVariable", valor);
II.- RECUPERAR LA SESION:
A.- JSP: request.getSession().getAttribute("miVariable");
B.- JSF: FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("miVariable");
III.- RECUPERANDO 'Context, Request, Response':
A.- JSP: En JSP es automatico al utilizar los Servlet.
B.- JSF: Se tiene que simular el manejo 'Context, Resquest, Response' tanto para el HttpServlet o el Servlet, segun se requiera.
- FacesContext context = FacesContext.getCurrentInstance();
- HttpServletRequest request = (HttpServletRequest)context.getCurrentInstance().getExternalContext().getRequest();
- HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
- ServletContext request2 = (ServletContext)context.getCurrentInstance().getExternalContext().getRequest();
- ServletContext sContext = (ServletContext)context.getExternalContext().getContext();
- ServletRequest sRequest = (ServletRequest)context.getExternalContext().getRequest();
- ServletResponse sResponse = (ServletResponse)context.getExternalContext().getResponse();
fuente: Blog Frameworks Java
No hay comentarios:
Publicar un comentario