It seems to me that in according to JSP Specification 1.1 the declarations
specified by
<%! ... %> JSP element are class-wide declarations.
If you do not specify that your JSP page is a single-threaded page, then it
is not safe to use the declared variables in the way you did:
> <%! String name=""; %>
> <%! int id=0; %>
> <% name = request.getParameter("name");
> id = Integer.parseInt(request.getParameter("id"));
> %>
The following code will be more robust.
<%
String name="";
int id=0;
name = request.getParameter("name");
id = Integer.parseInt(request.getParameter("id"));
%>
----- Original Message -----
From: goli <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 26, 1999 3:08 PM
Subject: Re: JSP population using bean
> Goli Wrote:
> Hi ,
> Here is the example program that uses bean.
> <html>
> <head>
> <title>greetings</title>
> </head>
> <body>
> <jsp:useBean id="mydata" scope="application" class="data.empdata" />
> <b>Data</b><p>
> <%! String name=""; %>
> <%! int id=0; %>
> <% name = request.getParameter("name");
> id = Integer.parseInt(request.getParameter("id"));
> %>
> <% mydata.setdata(id,name); %>
> <p><a href = "emphome.htm"> HOME </a></p>
> </body>
> </html>
>
> You have to use jsp:useBean directive in order to work with beans.
> in the above example empdata is a bean that is loaded in data directory.
> you can call bean functions using its id. see in above example
> mydata.setdata()
>
> Tx
> Goli
>
>
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Andrew Tyson
> Sent: Monday, October 25, 1999 8:34 PM
> To: [EMAIL PROTECTED]
> Subject: JSP population using bean
>
>
> Hello All,
>
> I am having difficulties with populating a bean referenced within a JSP.
> Basically I am trying to set a property of a bean from the input of a
simple
> HTML form. The following comes from 'hellobean.jsp'
>
> <%@ import = "HelloBean" %>
>
> <BEAN NAME="hello" TYPE="HelloBean"
> INTROSPECT="yes" CREATE="yes" SCOPE="request">
> </BEAN>
>
> <HTML>
> <HEAD><TITLE>Hello</TITLE></HEAD>
> <BODY>
> <H1>
> Hello, <%= hello.getName() %>
> </H1>
> </BODY>
> </HTML>
>
> Here is the source code for the bean;
>
> public class HelloBean {
>
> private String name = "World";
>
> public void setName(String name) {
> this.name = name;
> }
>
> public String getName() {
> return name;
> }
> }
>
> This JSP page comes from an example from a book and conforms to 0.9x
> release. I am using JavaWebServer 2.0, JSWDK 1.0.1 ( which is based on
> the 1.0 release of JSP I believe ) and JDK 1.2.2. I can't find any
reference
> to
> the <bean>...</bean> tags and I am wondering if they are deprecated from
> an earlier version of JSP.
>
> Whenever I enter the URL "localhost:8080/hellobean?name=fred" the server
> cannot successfully create the servlet based on the JSP file. I have
placed
> the bean source file in the 'classes' directory of the webserver.
>
> Any ideas? Example JSP would be much appreciated.
>
> Thanks and regards,
> AT
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html