Must I compile a bean for a JSP page?
I am trying to make a JSP page that also using a java bean.
When doing so, do I need to compile the bean myself and then put it into
the appropriate directory, (i.e. jswdk-1.0.1\examples\WEB-INF\jsp\beans\instantjsp1),
before accessing the JSP page through my browser, or will an instance of
my bean be made automatically when the JSP page is loaded..
This is the bean
package instantjsp1;
public class ScopeTest {
private int i;
public ScopeTest() {
i = 0;
}
public int getNextInt() {
return ++i;
}
}
JSP Page
<jsp:usebean id = "appScopeCount" scope = "application"
class = "instantjsp1.ScopeTest" />
<jsp:usebean id = "reqScopeCount" scope = "request"
class = "instantjsp1.ScopeTest" />
<html>
<head>
<title>Scope Test</title>
</head>
<body>
<br>
<br>
<br>
Counter (scope = application) has a value of
<jsp:getProperty name = "appScopeCount" property = "nextInt"/>
<br>
<br>
Counter (scope = request) has a value of
<jsp:getProperty name = "reqScopeCount" property = "nextInt"/>
<br>
<br>
<center>
<form method = get action = "ScopeTest.jsp">
<input type = submit name = "submit" value = "INCREMENT">
</form>
</center>
</body>
</html>
ClassPath used by server
Using classpath: .\classes;.\webserver.jar;.\lib\jakarta.jar;.\lib\servlet.jar;.
\lib\jsp.jar;.\lib\jspengine.jar;.\examples\WEB-INF\jsp\beans;.\webpages\WEB-INF
\servlets;.\webpages\WEB-INF\jsp\beans;.\lib\xml.jar;.\lib\moo.jar;\lib\tools.ja
r;.;C:\JDK12~1.1\lib\tools.jar;c:\javase~1\jswdk\jswdk-~1.1\examples\web-inf\jsp
\beans
Re: Must I compile a bean for a JSP page?
yes you do need to compile it yourself....unlike jsp's, the engine does no
precompilation for beans
Regards
John Timney (MVP)
Alison <Alison10@btinternet.com> wrote in message
news:397ef83f$1@news.devx.com...
>
> I am trying to make a JSP page that also using a java bean.
> When doing so, do I need to compile the bean myself and then put it into
> the appropriate directory, (i.e.
jswdk-1.0.1\examples\WEB-INF\jsp\beans\instantjsp1),
> before accessing the JSP page through my browser, or will an instance of
> my bean be made automatically when the JSP page is loaded..
>
> This is the bean
>
> package instantjsp1;
>
> public class ScopeTest {
> private int i;
> public ScopeTest() {
> i = 0;
> }
> public int getNextInt()
> return ++i;
> }
> }
>
> JSP Page
>
>
>
> <jsp:usebean id = "appScopeCount" scope = "application"
> class = "instantjsp1.ScopeTest" />
>
> <jsp:usebean id = "reqScopeCount" scope = "request"
> class = "instantjsp1.ScopeTest" />
>
> <html>
> <head>
> <title>Scope Test</title>
> </head>
>
> <body>
> <br>
> <br>
> <br>
> Counter (scope = application) has a value of
> <jsp:getProperty name = "appScopeCount" property = "nextInt"/>
> <br>
> <br>
> Counter (scope = request) has a value of
> <jsp:getProperty name = "reqScopeCount" property = "nextInt"/>
> <br>
> <br>
> <center>
> <form method = get action = "ScopeTest.jsp">
> <input type = submit name = "submit" value = "INCREMENT">
> </form>
> </center>
> </body>
> </html>
>
>
> ClassPath used by server
>
> Using classpath:
..\classes;.\webserver.jar;.\lib\jakarta.jar;.\lib\servlet.jar;.
>
\lib\jsp.jar;.\lib\jspengine.jar;.\examples\WEB-INF\jsp\beans;.\webpages\WEB
-INF
>
\servlets;.\webpages\WEB-INF\jsp\beans;.\lib\xml.jar;.\lib\moo.jar;\lib\tool
s.ja
>
r;.;C:\JDK12~1.1\lib\tools.jar;c:\javase~1\jswdk\jswdk-~1.1\examples\web-inf
\jsp
> \beans