tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebastian Schulz" <sebastian.sch...@sebastian-schulz.com>
Subject Re: best way to handle Servlets+JSPs+multiple Frames?
Date Wed, 21 Feb 2001 18:14:18 GMT
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.

----- Original Message -----
From: Jones, Stephen <sjones@rational.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Wednesday, February 21, 2001 6:51 PM
Subject: RE: best way to handle Servlets+JSPs+multiple Frames?


> In our product, we use forms to POST user input data. We usually send the
> input to another JSP page, but I don't see why this would not work for a
> servlet's doPost(HttpServletRequest, HttpServletResponse) method.
>
> e.g.:
> <form name="ReqAttMod" id="ReqAttMod" method="POST"
> action="UserMod_Ctl.jsp" target="_top">
> <% /* form stuff here, buttons, textfields, etc */ %>
> </form>
>
> When the servlet has made its controller-decisions, it then performs a
> URL-redirect to the new HTML frameset desired (sURL), according to biz
> logic, e.g.:
>
> response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
> response.setHeader("Location", sURL);
>
> (this is a cookie-safe redirect)
>
> I'm sure there are other ways, as well.
> Steve
>



Mime
View raw message