tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Smith" <>
Subject Re: Help.. I cannot use classes in JSP code itself!!
Date Tue, 21 Nov 2000 15:30:35 GMT

Naturally. The following JSP creates an inner class and then counts as the
page is reloaded. Keep in mind
that JSP's are just servlets and servlets are just java classes. There are
no special restrictions. Please
consult a good book on java for more details on constructing Inner classes.

Also, please stop posting general java questions to the list.



******************************START CODE********************
 public class TestInner {
  private int count = 0;
  public void increment() { count++; }
  public String toString() { return ""+count; }
 TestInner inner = new TestInner();



<H1>Count: <% inner.increment(); %><%=inner%></H1>


**************************END CODE*****************

----- Original Message -----
From: "Winnie Cheung" <>
To: <>
Sent: Tuesday, November 21, 2000 4:52 AM
Subject: Help.. I cannot use classes in JSP code itself!!

> Hello..
> Can I write my own simple classes within the JSP code? I mean within the
> %>" tags? I have been trying to do this but its giving me an error all the
> time!
> I want to do this because I would like to avoid the rigmarole of going
> through all these directory structures and all that with servlets!
> Thanks very much for the patience, I am a very new user.
> Best regards
> Winnie

View raw message