JS Newbie Needs Help!

S

Steve Burrus

I am trying to get a JavaScript alert dialogue box to pop up in a
particular servlet!! Now, I know that there is no JS at work with a
server, i.e., in a servlet!! I am supposed to put the JS alert in the
html file that is associated with the servlet?? Right?
 
S

Steve Burrus

Thanx for the "stroking" or congratulations for "finding my way" over to
the c.l.s., andrew (Could it possibly be "Andy" perhaps??! :))

Listen, I last nite "got it right" with being able to see a JavaScript
alert box pop up with a servlet!! But I did it a little bit differently
than how u did it!

You see, instead of using those 2 "getAlert()" methods of yours', I
merely put the JS method "onLoad()" into my <body></body> tag, this was
after I specified in the <head> tag that I would like to use some
version of JavaScript. Say, I did this successfully last nite in a html
file which I wanted associated with my serlvet, BUT what if I have just
a "stand-alone" servlet (with absolutely no html file that I want
associated with it), how then do I get the alert dialogue box to
possibly pop up when the Java Servlet loads into my favorite web browser
anyway??? You would definitely make a friend for life out of me IF you
can solve this one for me. Capiche?? And finally, are you some kind of
an expert on both Java and also JavaScript? As for me, I have been
practicing for a while on the server side of Java Programming, i.e., the
J2EE.
 
R

Richard Cornford

Steve Burrus wrote:
You see, instead of using those 2 "getAlert()" methods of yours', I
merely put the JS method "onLoad()" into my <body></body> tag, this
was after I specified in the <head> tag that I would like to use some
version of JavaScript. Say, I did this successfully last nite in a
html file which I wanted associated with my serlvet, BUT what if I
have just a "stand-alone" servlet (with absolutely no html file that
I want associated with it), how then do I get the alert dialogue box
to possibly pop up when the Java Servlet loads into my favorite web
browser anyway??? You would definitely make a friend for life out of
me IF you can solve this one for me. Capiche?? And finally, are you
some kind of an expert on both Java and also JavaScript? As for me,
I have been practicing for a while on the server side of Java
Programming, i.e., the J2EE.
<snip>

So long as you continue to fail to recognise the separation of
server-side activity from client-side you will continue to waste a lot
of your time banging your head against a wall.

The sequence goes:-

1. A browser makes an HTTP request.

2. That request finds its way to your Java application server.

3. Your server reconciles the request with your servlet and
executes a method on the servlet, making a request object
available for examination.

4. The servlet builds contents for a response object and passes
it back to the application server, which sends it back to the
browser as an HTTP response.

5. The browser receives the HTTP response and interprets it in
some way, usually as HTML (+javascript, possibly), depending
on the content type sent.

6. The browser displays the HTML and executes the javascript (or
does whatever it is configured to do with other content types).

When considering client-side scripting only the last two stages are
relevant. What the browser receives in the response, and what it does
with it. The role of the servlet is to build the contents of the
response, but it has finished its job before the browser gets to see
anything.

Separate these stages in your mind. What you need to know in order to
solve the - alert - problem (or any client-side scripting problem) is
what combination of HTML and javascript will do what you want when it is
loaded into a web browser. The situation needs to be thought about in
those terms, and the question asked in those terms (possibly/preferably
with some additional explanation of context and purpose, that should
include mention of the existence of a Java back-end).

Once you know what the browser needs to be receiving then you can move
on to the problems of getting your servlet to create and send it (and
that stage would be a Java question).

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top