Re: Introspect whether setCharacterEncoding is present..
Endre Stølsvik <[email protected]> Tue, 12 Oct 2004 17:17:10 +0200 (CEST)
| Newsgroups | gmane.comp.java.advanced-servlets |
|---|---|
| Message-ID | <Pine.LNX.4.44.0410121711110.26253-100000@excalibur.intra.coretrek.com> |
Thanks for answers/opinions!
On Tue, 12 Oct 2004, Charles Forsythe wrote:
|
| Endre Stølsvik wrote:
|
| >See, the problem is that we would like our application to be 2.2
| >compliant, but we'd love to use the setCharactherEncoding method if it is
| >available (>= 2.3 envs).
| >
| If an API "level test" is appropriate, it would be a lot cleaner (and
| faster) to test for the existence of a 2.3 class, rather than looking
| for the setCharacterEncoding method via reflection.
Why?
| You could set a Context Attribute (or other flag) based on the
| following test:
|
| try {
| Class.forName("javax.servlet.http.HttpServletRequestWrapper");
| // This is Servlet API >= 2.3 --> Set Attribute/Flag TRUE
| } catch(ClassNotFoundException cnfx) {
| // This is Servlet API < 2.3 --> Set Attribute/Flag FALSE
| }
What it seems like we'll end up on, is to ask the servlet API for its
version, then if (major >= 3 || (major == 2 && minor >= 3)), then
introspect the method and invoke it (so that we still can compile on
servlet2.2.jar).
What would be the benefit of your check, as opposed to introspection?
I'd say that the check for a class' existence is just as much
introspection as simply using the actual introspection engine to "look
this up"?
Endre
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->
Before posting a question, try to find your answer here:
<http://www.egroups.com/links/advanced-servlets>
Announcements should go to: [email protected]
To Post a message, send it to: [email protected]
To Unsubscribe, send a blank message to: [email protected]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/advanced-servlets/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/