You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dan Hinojosa <dh...@qwest.net> on 2001/07/31 18:39:34 UTC

Java Beans and JSP Question.

I have a standard java bean.  The different thing about it is that I
usually have two overloaded set methods per attribute.  For example,

public class MyBean {
    private int a;

    public setA (int a) throws Exception {
        if (a > 100) throw new Exception ("Must be less than 100");
    }

    public setA (String a) throws Exception {
        try {
            setA(Integer.parseInt(a));
        } catch (NumberFormat Exception exception) {
            throw new Exception ("Format incorrect.");
        }
    }

    //I usually have one getA
    public int getA() {
        return a;
    }
}


Now when I use this bean in a JSP that is stored in the request scope,
at times the compiler will complain that it cannot find a get method for
"A".  Even though one get method for that particular attribute is
clearly there.

Some added information, I use Forte Community Edition 2, and Tomcat.
Forte's compiler complains about one attribute while Tomcat complains
about another completely different attribute it cannot find the get
method for.  Which makes me itch with anger.  The note is my example
above is very simple. I used it just to explain my problem.  My actual
bean has about 17 attributes all with 2 setter methods each and 1 get
method each.

Does anyone know how to resolve this issue?

Thanks for your help.
Dan Hinojosa




AW: Java Beans and JSP Question.

Posted by Nikolic Branislav <ni...@niki.at>.
UNSUBSCRIBE!!!

-----Ursprungliche Nachricht-----
Von: Craig R. McClanahan [mailto:craigmcc@apache.org]
Gesendet: Dienstag, 31. Juli 2001 23:52
An: tomcat-user@jakarta.apache.org
Betreff: Re: Java Beans and JSP Question.


On Tue, 31 Jul 2001, Dan Hinojosa wrote:

> I have a standard java bean.  The different thing about it is that I
> usually have two overloaded set methods per attribute.

Doing this violates the design patterns for getters and setters listed in
the JavaBeans specification.  Therefore, the JDK's introspection logic
will not recognize this as a property.

You need to either have only one setter (with a type that matches the
corresponding getter), or you must define a BeanInfo class that
specifically lists the method names and parameter types of your getter and
setter methods.

Craig McClanahan


Deploying precompiled jsp without .jsp file

Posted by Shahed A Moolji <sh...@enoor.com>.
Hi,

Is it possible to distribute precompiled jsp's using
standalone tomcat, but not distribute the .jsp source file ?

Also, is the same possible when tomcat is integrated with
Apache etc ?

ie. I go to http://myserver.com:8080/a.jsp and a.jsp does not exist
under the webapps/<context> directory, but a precompiled class
does exist under the WORK directory.

Thanks
Shahed.


RE: Default Servlet prevents loading of static resources.

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 2 Aug 2001, Miles Daffin wrote:

> Thanks Craig (see below) - reliable as ever.
> 
> That was the only conclusion I could come to: to start 
> serving my own static content. A bit of a pain.
> 
> As to what I am doing - experimenting with aspects of the 
> 2.2 Spec. Making myself aware of the options. 
> 
> What might one use a default servlet for?? I thought
> I knew. Turns out I was wrong.

Well, not every web app necessarily has static content.  Or, you might
want to customize the serving of static content in some way (and thereby
override the default file-serving capability of your container).

In practice, I've never found a need to replace this myself.

> 
> Miles
> 

Craig


>  
> 
> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: Wednesday, August 01, 2001 7:50 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: Default Servlet prevents loading of static resources.
> 
> 
> On Wed, 1 Aug 2001, Miles Daffin wrote:
> 
> > Hi There TC Peeps,
> > 
> > I have added a default servlet to a little test webapp
> > (<servlet-mapping>/</servlet-mapping>). 
> > 
> > After I did this I can no longer access static resources 
> > (html, images etc.) in the app. 
> > 
> > All requests, apart from those to other (mapped) servlets 
> > are picked up by the default. e.g. I have an index.html in the 
> > apps <welcome-file-list> that cannot be got at implicitly or
> > explicitly.
> > 
> > The same behaviour is noted in ORION.
> > 
> > 1. Have I noticed something strange, or should it be this way?
> > 2. If it should be this way what is the use of a default servlet?
> >    (Can anyone give an example of usage?)
> > 
> > Miles
> > 
> 
> In Tomcat at least (don't know about Orion but sounds like it might be the
> same), static file serving is implemented as the "default" default servlet
> :-).  Defining your own default servlet means that the file-serving
> servlet will never see the request, so it becomes your responsibility to
> serve static content.
> 
> What's your objective for defining your own default servlet?  There might
> be another way to approach that problem.
> 
> Craig McClanahan
> 
> 
> 
> 


RE: Default Servlet prevents loading of static resources.

Posted by Miles Daffin <md...@infpwr.com>.
Thanks Craig (see below) - reliable as ever.

That was the only conclusion I could come to: to start 
serving my own static content. A bit of a pain.

As to what I am doing - experimenting with aspects of the 
2.2 Spec. Making myself aware of the options. 

What might one use a default servlet for?? I thought
I knew. Turns out I was wrong.

Miles

 

-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Wednesday, August 01, 2001 7:50 PM
To: tomcat-user@jakarta.apache.org
Subject: Re: Default Servlet prevents loading of static resources.


On Wed, 1 Aug 2001, Miles Daffin wrote:

> Hi There TC Peeps,
> 
> I have added a default servlet to a little test webapp
> (<servlet-mapping>/</servlet-mapping>). 
> 
> After I did this I can no longer access static resources 
> (html, images etc.) in the app. 
> 
> All requests, apart from those to other (mapped) servlets 
> are picked up by the default. e.g. I have an index.html in the 
> apps <welcome-file-list> that cannot be got at implicitly or
> explicitly.
> 
> The same behaviour is noted in ORION.
> 
> 1. Have I noticed something strange, or should it be this way?
> 2. If it should be this way what is the use of a default servlet?
>    (Can anyone give an example of usage?)
> 
> Miles
> 

In Tomcat at least (don't know about Orion but sounds like it might be the
same), static file serving is implemented as the "default" default servlet
:-).  Defining your own default servlet means that the file-serving
servlet will never see the request, so it becomes your responsibility to
serve static content.

What's your objective for defining your own default servlet?  There might
be another way to approach that problem.

Craig McClanahan




Re: Default Servlet prevents loading of static resources.

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Wed, 1 Aug 2001, Miles Daffin wrote:

> Hi There TC Peeps,
> 
> I have added a default servlet to a little test webapp
> (<servlet-mapping>/</servlet-mapping>). 
> 
> After I did this I can no longer access static resources 
> (html, images etc.) in the app. 
> 
> All requests, apart from those to other (mapped) servlets 
> are picked up by the default. e.g. I have an index.html in the 
> apps <welcome-file-list> that cannot be got at implicitly or
> explicitly.
> 
> The same behaviour is noted in ORION.
> 
> 1. Have I noticed something strange, or should it be this way?
> 2. If it should be this way what is the use of a default servlet?
>    (Can anyone give an example of usage?)
> 
> Miles
> 

In Tomcat at least (don't know about Orion but sounds like it might be the
same), static file serving is implemented as the "default" default servlet
:-).  Defining your own default servlet means that the file-serving
servlet will never see the request, so it becomes your responsibility to
serve static content.

What's your objective for defining your own default servlet?  There might
be another way to approach that problem.

Craig McClanahan



Default Servlet prevents loading of static resources.

Posted by Miles Daffin <md...@infpwr.com>.
Hi There TC Peeps,

I have added a default servlet to a little test webapp
(<servlet-mapping>/</servlet-mapping>). 

After I did this I can no longer access static resources 
(html, images etc.) in the app. 

All requests, apart from those to other (mapped) servlets 
are picked up by the default. e.g. I have an index.html in the 
apps <welcome-file-list> that cannot be got at implicitly or
explicitly.

The same behaviour is noted in ORION.

1. Have I noticed something strange, or should it be this way?
2. If it should be this way what is the use of a default servlet?
   (Can anyone give an example of usage?)

Miles

Re: Java Beans and JSP Question.

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 31 Jul 2001, Dan Hinojosa wrote:

> I have a standard java bean.  The different thing about it is that I
> usually have two overloaded set methods per attribute.

Doing this violates the design patterns for getters and setters listed in
the JavaBeans specification.  Therefore, the JDK's introspection logic
will not recognize this as a property.

You need to either have only one setter (with a type that matches the
corresponding getter), or you must define a BeanInfo class that
specifically lists the method names and parameter types of your getter and
setter methods.

Craig McClanahan