tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kenneth.baltz" <kenneth.ba...@inforonics.com>
Subject RE: Passing parameters to a bean from a JSP
Date Wed, 05 Apr 2000 20:03:22 GMT
This still sounds like a Chicken and the Egg problem, but if all you are
asking is how to get the value that someone submitted from a form, just get
it from request.getParameter( "State" ) or whatever the control you want the
value from is called.  

I think you are gettings answers you don't like because it sounds like you
want your JSP to process on the client side.  What I heard you say is that
you want to have the user pick something from one select box and then, based
on that choice, have a certain set of options "appear" in a second select
box.  This cannot be done with JSP without a hit to the server.  It could be
done with JavaScript, but then you'd have to have all the information
already available and you already said that wasn't feasible.  You could have
some JavaScript submit your form when they select the first select box, and
then resend the form with the appropriate choices in the second select box.


HTH,
K.C.

> -----Original Message-----
> From: Jerry Thomas [mailto:jerry_thomas@hotmail.com]
> Sent: Wednesday, April 05, 2000 3:32 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: Passing parameters to a bean from a JSP
> 
> 
> All of the data I need from the bean behind my JSP is 
> retrieved as the JSP 
> is executed. There is too much data to throw into the HTML 
> FORM at any one 
> time. The HTML FORM portion of my JSP is basically a shell 
> that I populate 
> by calling methods on my Java bean that return data to  my 
> JSP and can then 
> be inserted using JavaScript into the HTML. So far I have had 
> success using 
> JSP and Java beans to create the interfaces that I have been 
> working on. I 
> believe that I have over-complicated a simple question. The 
> question is...
> 
> If I have the following code in my JSP:
> <% int i;
>    mybean.mymethod(i); %>
> 
> How can I assign "i" with data from my HTML form that is 
> outside of the <%%> 
> tags?
> 
> 
> >From: "Troy Mac Neil" <tmacneil@trakonic.com>
> >Reply-To: tomcat-user@jakarta.apache.org
> >To: <tomcat-user@jakarta.apache.org>
> >Subject: Re: Passing parameters to a bean from a JSP
> >Date: Wed, 5 Apr 2000 14:03:48 -0300
> >
> >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
> > >
> >
> >
> >-------------------------------------------------------------
> -------------
> >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