AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

loading a servlet in a frame..

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Frances Del Rio
Guest





PostPosted: Fri Nov 26, 2004 7:23 am    Post subject: loading a servlet in a frame.. Reply with quote




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
to servlet in url-pattern in web.xml is, say /myServlet, and in form I
have action=myServlet, how would I load the servlet into the bottom
frame? thank you.. Frances

Back to top
PerfectDayToChaseTornados
Guest





PostPosted: Sat Nov 27, 2004 11:39 am    Post subject: Re: loading a servlet in a frame.. Reply with quote




"Frances Del Rio" <fdr58 (AT) yahoo (DOT) com> wrote

Quote:

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
to servlet in url-pattern in web.xml is, say /myServlet, and in form I
have action=myServlet, how would I load the servlet into the bottom
frame? thank you.. Frances


Hi Frances, I probably wouldn't use a frame Smile Frames have been deprecated
by W3C & are a real pain for usability (problematic for screen readers etc).
I would either return to the same jsp & have dynamic output in the bottom
part, or have the form as an include & include it in the submission & result
page. To do it using frames would be more complicated as your servlet would
have to return the frameset, you would then need to pick up attributes in
the jsp called from the bottom half of the frameset.

Also in regard to your previous post, the advantage of not being able to
"browse" to WEB-INF & it's subdirectories is security. It means that you can
control (via servlets) exactly what gets served from there. It is a pretty
common pattern to put secure jsps in subdirectories under the WEB-INF
directory.

HTH
--
-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)



Back to top
Frances Del Rio
Guest





PostPosted: Mon Nov 29, 2004 4:27 pm    Post subject: Re: loading a servlet in a frame.. Reply with quote





PerfectDayToChaseTornados wrote:
Quote:
"Frances Del Rio" <fdr58 (AT) yahoo (DOT) com> wrote in message
news:30o3vpF31rhldU1 (AT) uni-berlin (DOT) de...
|
| 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
| to servlet in url-pattern in web.xml is, say /myServlet, and in form I
| have action=myServlet, how would I load the servlet into the bottom
| frame? thank you.. Frances
|

Hi Frances, I probably wouldn't use a frame Smile Frames have been deprecated
by W3C & are a real pain for usability (problematic for screen readers etc).
I would either return to the same jsp & have dynamic output in the bottom
part, or have the form as an include & include it in the submission & result
page. To do it using frames would be more complicated as your servlet would
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


Back to top
PerfectDayToChaseTornados
Guest





PostPosted: Tue Nov 30, 2004 9:43 pm    Post subject: Re: loading a servlet in a frame.. Reply with quote



"Frances Del Rio" <fdr58 (AT) yahoo (DOT) com> wrote

Quote:


PerfectDayToChaseTornados wrote:
"Frances Del Rio" <fdr58 (AT) yahoo (DOT) com> wrote in message
news:30o3vpF31rhldU1 (AT) uni-berlin (DOT) de...
|
| 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
| to servlet in url-pattern in web.xml is, say /myServlet, and in form I
| have action=myServlet, how would I load the servlet into the bottom
| frame? thank you.. Frances
|

Hi Frances, I probably wouldn't use a frame Smile Frames have been
deprecated
by W3C & are a real pain for usability (problematic for screen readers
etc).
I would either return to the same jsp & have dynamic output in the
bottom
part, or have the form as an include & include it in the submission &
result
page. To do it using frames would be more complicated as your servlet
would
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

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 Wink 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 Smile
--
-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)



Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.