
Signature
-P
"Programs that are hard to read are hard to modify.
Programs that have duplicated logic are hard to modify.
Programs with complex conditional logic are hard to modify"
( Kent Beck)
> | I have a frameset w/two frames, top frame is form, when user hits
> | 'submit' I want servlet to load and execute in bottom frame.. if path
[quoted text clipped - 9 lines]
> have to return the frameset, you would then need to pick up attributes in
> the jsp called from the bottom half of the frameset.
thank you for your response, TornadoChaser... I had not seen it until
now.. you responded also to my other post, about how to do this (have
return stuff print on same window..) w/a jsp.. but I have not been able
to make that work.. I still want to do it, I'm learning and this app is
more a learning exercise than anything else.. I did manage to load the
servlet into another frame (frames -- deprecated? sorry, I think that's
ridiculous, there's lots of cool stuff you can do w/frames if you use
them right..) check it out..
www.francesdelrio.com/hamlet..
it turns out it was quite easy, not a java question at all, all I had to
do was put "target='main'" (name of frame) in form tag to indicate I
want results of form submission to show up in other frame.. had no idea
until now you could put a target attr in form tag.. you never finish
learning little things.... ;)
I still want to make a jsp version of this (again, this is a learning
exercise..) so: maybe I can now still try do what you said and do it all
on one frame in jsp? (the way it works now though, in servlet version
that loads in another frame, when user hits 'reload' it gets 'cleaned
up' and return disappears and bottom frame returns to being empty..
could I do this effect in jsp? w/everyting in same frame?) here's
source code of current servlet..
www.francesdelrio.com/java/hamlet.html
am trying to figure out how to best 'convert' this to jsp.. the
confusing part to me about what you sent me was how jsp 'reads' from
servlet.. this part..
<% String myWord = (String) request.getAttribute("yourattributename");
if(myWord == null){
myWord = "";
} %>
how does jsp here know what servlet to read from? I put everything you
wrote that time in a one-pg word file, for easier ref.. in case you
forgot what you wrote.. www.francesdelrio.com/java/how-to.doc.. thank
you again very much.. Frances
PerfectDayToChaseTornados - 30 Nov 2004 21:43 GMT
| > | I have a frameset w/two frames, top frame is form, when user hits
| > | 'submit' I want servlet to load and execute in bottom frame.. if path
[quoted text clipped - 50 lines]
| forgot what you wrote.. www.francesdelrio.com/java/how-to.doc.. thank
| you again very much.. Frances
Hi Frances,
The Servlet forwards to the jsp. So you still submit to a Servlet, the
Servlet does the processing & then forwards the request to the jsp, the jsp
then accesses the attributes you put in the request or session. It is best
to keep as much code out of jsps as possible & to do your processing in a
Servlet.
If you are still insistent on using frames ;-) then you will need to set the
attributes with session scope before you return the frameset, as the
frameset then makes a new HTTP request for each contained frame. You can
then access the attributes in the jsp, but you will probably also want to
remove them from the session after using them with
session.removeAtrribute(attname).
As for includes, you can include jsp content in other jsps, see these links
here for details
http://java.sun.com/products/jsp/syntax/1.1/syntaxref1112.html
http://java.sun.com/products/jsp/syntax/1.1/syntaxref117.html#8772
This is also an excellent jsp syntax ref you can print out.
http://java.sun.com/products/jsp/syntax/1.2/card12.pdf
If I understand you correctly you want your 'do it again' button to clear
all of the output on the page. You can do that by submitting to the Servlet
& clearing the variables. If they are request scope anyway, just returning
the page will have cleared the variables.
With regard to frames, I agree they can be useful. But they can also be over
used & lead to inelegant solutions. But the fact is they are deprecated & do
cause problems for people with screen readers. I try to avoid them now if
possible & look for other solutions. 99% of the time there are more elegant
ways to achieve the same thing :-)
HTH :-)

Signature
-P
"Programs that are hard to read are hard to modify.
Programs that have duplicated logic are hard to modify.
Programs with complex conditional logic are hard to modify"
( Kent Beck)