tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Troy Mac Neil" <tmacn...@trakonic.com>
Subject Re: Passing parameters to a bean from a JSP
Date Wed, 05 Apr 2000 17:03:48 GMT
It's been a while since I've done any client-side JavaScript, but if I
understand what you're trying to do, you either have to include all the
necessary data in you're first page or make another connection to the
server. Once the page is displayed in your browser, the JSP has finished
executing and you must reconnect to get more data.

Here is some JavaScript code that will do what you want by including the
counties in JavaScript arrays:
http://members.aol.com/grassblad/html/selCascade1.html

Or if you want to reconnect to the server to generate the second menu have
the first menu call the JSP again with different parameters (i.e.:
/mypage?state=florida) by setting  location.href to the new url.

The only other option would be to try using some sort of keep-alive
connection scheme
(http://www.javaworld.com/javaworld/jw-03-2000/jw-03-pushlet.html), but
that's probably much too complex and resource intensive for your needs.

Troy

--------------------------
Troy MacNeil
Software Designer
Packetware
http://www.trakonic.com
tmacneil@trakonic.com
--------------------------

----- Original Message -----
From: Jerry Thomas <jerry_thomas@hotmail.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Wednesday, April 05, 2000 10:46 AM
Subject: Re: Passing parameters to a bean from a JSP


> The responses that I have received on this subject have made it clear that
I
> have not stated my problem as clear as I should have. Let me try again...
>
> I do understand how to pull values from a request object once an HTML page
> has been submitted. What I am trying to do on my current JSP is pull data
> 'on the fly' to send to my bean. The current exercise is to create two
> "SELECT" type objects on my FORM. The first SELECT object is populated
with
> the states of the United States. The second SELECT object is left blank
> until the user selects a state from the first SELECT object. I would then
> like to dynamically enter all of the counties for the selected state into
> the 2nd SELECT object. Currently I have most of this working. The JSP
draws
> an HTML FORM, calls a JavaScript function that uses the JSP Java bean to
> connect to my database and return a Vector object containing all of the
> states, using JavaScript I populate the SELECT object and then wait for
user
> input. JavaScript detects the 'onChange' event associated with the SELECT
> object containing the states and passes an Object containing the SELECT
> object to another JavaScript function that pulls out the selected state as
> selected by the user. So far so good. Here comes my problem...
> I would like to pass the selected state back to my JSP Java bean to
retrieve
> a Vector containing the counties for the selected state. I can in fact
hard
> code a string that is passed back and retrieve the Vector of counties.
What
> I cannot figure out how to do is to pass text obtained from my HTML FORM
> (like a state selected from the SELECT object)as a parameter to my Java
> bean.
> Is there a way to use scriptlets in a JSP to move data from variables
> obtained from HTML (using JavaScript or otherwise) into a Java variable or
> parameter list?
>
>
>
>
>
> >From: Russell Hammer <russ@perneus.com>
> >Reply-To: Russell Hammer <russ@perneus.com>
> >To: tomcat-user@jakarta.apache.org
> >Subject: Re: Passing parameters to a bean from a JSP
> >Date: Tue, 4 Apr 2000 09:56:52 -0400 (EDT)
> >
> > > This HTML:
> > >
> > > <HTML>
> > > <HEAD><TITLE>Example</TITLE></HEAD>
> > > <BODY>
> > > <H1>Your Name:</H1>
> > > <FORM TYPE=POST ACTION=hello.jsp>
> > > <INPUT TYPE=TEXT NAME=YOURNAME>
> > > </FORM>
> > > </BODY>
> > > </HTML>
> > >
> > > With this hello.jsp:
> > >
> > > <HTML>
> > > <HEAD><TITLE>Example</TITLE></HEAD>
> > > <BODY>
> > > <H1>Hello <% =request.getParameter("YOURNAME") %></H1>
> >
> >Shouldn't this be
> >
> >   <H1>Hello <%= request.getParameter("YOURNAME") %></H1>
> >
> > > </BODY>
> > > </HTML>
> > >
> > > Should work. You can also check some of the examples at
> > > /path/to/tomcat/webapps/examples/jsp.
> > >
> > > Can you post come of your HTTML/Javascript and your JSP?.
> >
> >Russ
> >
> >
>
>--------------------------------------------------------------------------
> >To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commmands, email: tomcat-user-help@jakarta.apache.org
> >
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
>
> --------------------------------------------------------------------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org
>


Mime
View raw message