tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Lazlo <mla...@ndc-nfi.com>
Subject Re: Passing parameters to a bean from a JSP
Date Wed, 05 Apr 2000 15:49:22 GMT
Jerry,
Try this:
<%@ page language="java" import="stateBean" %>
<jsp:useBean id="stateBean" scope="page" class="stateBean" />
<jsp:setProperty name="stateBean" property="*" />

<html>
<BODY>
<FORM METHOD="post">
    <SELECT name="State">
            <OPTION SELECTED>New York
            <OPTION>New Jersey
         </SELECT>
         <BR><BR><BR>
         <INPUT TYPE=submit VALUE="Submit">
      </FORM>
...
</BODY>
</HTML>

With this above you would need a method call setState in a bean called
stateBean.

--
___________________________________________________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mike Lazlo
Technical Manager/DBA
mlazlo@ndc-nfi.com
1-800-922-5088 ext. 4758


Jerry Thomas wrote:

> 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