DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    Alison Guest

    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 &nbsp;
    <jsp:getProperty name = "appScopeCount" property = "nextInt"/>
    <br>
    <br>
    Counter (scope = request) has a value of &nbsp;
    <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

  2. #2
    John Timney (MVP) Guest

    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 &nbsp;
    > <jsp:getProperty name = "appScopeCount" property = "nextInt"/>
    > <br>
    > <br>
    > Counter (scope = request) has a value of &nbsp;
    > <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




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links