tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jones, Stephen" <sjo...@rational.com>
Subject RE: best way to handle Servlets+JSPs+multiple Frames?
Date Wed, 21 Feb 2001 20:57:25 GMT
Sebastian:

I do not understand any added significance with regards to session
information. All JSP pages and servlets have access to the session Object
provided by Tomcat. The session is shared across any number of different
requests coming in from the client...

What I mean is that any page can retrieve the object your servlet has
modified, the same way the servlet got it:
object = (cast) session.getAttribute(..);

Really, though-- it seems like your object should be a session-scope bean.
Then the "view" JSP pages can retrieve the object via useBean tags.

Steve

> -----Original Message-----
> From: Sebastian Schulz [mailto:sebastian.schulz@sebastian-schulz.com]
> Sent: Wednesday, February 21, 2001 12:10 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: best way to handle Servlets+JSPs+multiple Frames?
> 
> 
> hi Stephen,
> 
> thank you for your solution.
> 
> But if i'm not mistaken your example needs
> no session (therefor the redirection, right?)
> 
> Then it's no problem to have one frame
> making the Request and the Servlet after
> doing its job redirects to the URL with the
> Frameset.
> 
> But i need session-support for the whole Lifetime
> of the WebApplication, so thats my abstract use-case:
> 
> request (for instance form-data) from one frame, servlet
> validates and changes some Java-Objects, putting them
> back to session, then _dispatching_ , better _forwarding_
> the request to the frameset.
> because the frameset consists of several "JSP-Frames", whitch all
> needs access to the session-object, i can not dispatch to the
> frameset, instead i have to dispatch to that frame, which has made the
> request (with help from a JavaScript-Function).
> 
> Am I wrong?
> 
> here some code-snippets:
> 
> frame with form, action as a redirection to a JavaScript-Function:
> <form method="post" ... 
> action="javascript:dispatchFrames('Servlet-Path')">
> ....
> ....
> <sript language = ...>
> function dispatchFrames(servletpath){
> /* reading form-parameters etc.
>     then dispatching for that frames who need access to modified
> session-object:
> */
> parameterlist=.....
> ....
> parent.frames[0].location.href=servletpath+"?"+parameterlist;
> parent.frames[1].location ...same
> ... and so on
> 
> Servlet:
> /* doGet() + doPost(): */
> ...public void doIt(...) ...
> /* get my Object from Session: */
> object = (cast)session.getSessionAttribute(..);
> /* changing the object acording to request-parameters */
> /* no explicit store back, because call by reference */
> /* dispatch to that file(jsp), the requesting frame should 
> display now: */
> RequestDispatcher rd = getServletContext().getRequestDispatcher(url);
> try{
> ...
> ...
> res.setHeader(...
> rd.forward(req,res);
> ....
> 
> this is my solution, witch work also with session-suport for frames,
> but i'm not very happy with it.
> 
> bAs T.

--SNIP--

Mime
View raw message