Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Servlet forwarding question - compiles but won't run

5 views
Skip to first unread message

Jeremy Russell

unread,
Mar 7, 2002, 12:18:25 PM3/7/02
to
I am attempting to write a typical login servlet, that will then
forward control to another servlet after a successful entry of a login
name and password. The environment I am using is an Oracle 9i
database on Windows 2000, together with the Apache and jar files
supplied by Oracle.

Here is the relevant code fragment:

...
session.putValue("userName", sLoginName); // Save valid user name
// now we need to transfer the control to another servlet
debug("Attempting getRequestDispatcher()");
RequestDispatcher rd =
getServletContext().getRequestDispatcher("/servlet/IsItWorking");
debug("doPost() - return from getRequestDispatcher()");

if (rd != null)
{
rd.forward(request,response);
}

When I compile this code, I get this deprecation warning:

Warning: method putValue(java.lang.String, java.lang.Object)
in interface javax.servlet.http.HttpSession has been deprecated.

This may give a clue as to the version of the servlet engine I'm
using.

When I execute the servlet, I am getting the following in 'jserv.log':

attempting getRequestDispatcher()
java.lang.NoSuchMethodError: javax.servlet.ServletContext:
method
getRequestDispatcher(Ljava/lang/String;)Ljavax/servlet/RequestDispatcher;

not found
at
org.apache.jserv.JServConnection.processRequest(JServConnection.java:320)
at
org.apache.jserv.JServConnection.run(JServConnection.java:188)
at java.lang.Thread.run(Thread.java:479)

This has occupied me for most of yesterday and today - all suggestions
very gratefully accepted please!

TIA

Jeremy Russell

unread,
Mar 7, 2002, 12:39:47 PM3/7/02
to
And I forgot to say that the following is then displayed on execution
in my browser, not that I suspect it makes any difference to my
problem description:

Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, y...@your.address and inform
them of the time the error occurred, and anything you might have
done that may have caused the error.

More information about this error may be available in the server
error log.

Jon Skeet

unread,
Mar 7, 2002, 1:03:38 PM3/7/02
to
(There's no need to crosspost, btw. Most of the people answering tend to
read both of the groups you asked in.)

Jeremy Russell <jeremy....@usa.net> wrote:
> I am attempting to write a typical login servlet, that will then
> forward control to another servlet after a successful entry of a login
> name and password. The environment I am using is an Oracle 9i
> database on Windows 2000, together with the Apache and jar files
> supplied by Oracle.
>
> Here is the relevant code fragment:
>
> ...
> session.putValue("userName", sLoginName); // Save valid user name
> // now we need to transfer the control to another servlet
> debug("Attempting getRequestDispatcher()");
> RequestDispatcher rd =
> getServletContext().getRequestDispatcher("/servlet/IsItWorking");
> debug("doPost() - return from getRequestDispatcher()");
>
> if (rd != null)
> {
> rd.forward(request,response);
> }
>
> When I compile this code, I get this deprecation warning:
>
> Warning: method putValue(java.lang.String, java.lang.Object)
> in interface javax.servlet.http.HttpSession has been deprecated.
>
> This may give a clue as to the version of the servlet engine I'm
> using.

Nope, that gives a clue as to the verison of the servlet API you're
*compiling* against. That may or may not be the same as your actual
runtime servlet engine.



> When I execute the servlet, I am getting the following in 'jserv.log':
>
> attempting getRequestDispatcher()
> java.lang.NoSuchMethodError: javax.servlet.ServletContext:
> method
> getRequestDispatcher(Ljava/lang/String;)Ljavax/servlet/RequestDispatcher;
>
> not found
> at
> org.apache.jserv.JServConnection.processRequest(JServConnection.java:320)

So, you're using JServ at runtime. JServ only implements v2.0 of the
servlet API, which doesn't have ServletContext.getRequestDispatcher.
You'll either have to not use it, or change servlet engine.

--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

Jeremy Russell

unread,
Mar 7, 2002, 1:59:26 PM3/7/02
to
On Thu, 7 Mar 2002 18:03:38 -0000, Jon Skeet <sk...@pobox.com> wrote:

>(There's no need to crosspost, btw. Most of the people answering tend to
>read both of the groups you asked in.)

Ooops. No more x-posting then.

Thanks for the info - is there no corresponding mechanism in Jserv
then?

Jon Skeet

unread,
Mar 7, 2002, 2:26:56 PM3/7/02
to
Jeremy Russell <jeremy....@usa.net> wrote:
> Thanks for the info - is there no corresponding mechanism in Jserv
> then?

I don't know, to be honest - I don't believe so. Any reason not to
upgrade to Tomcat?

Jeremy Russell

unread,
Mar 7, 2002, 2:50:10 PM3/7/02
to
On Thu, 7 Mar 2002 19:26:56 -0000, Jon Skeet <sk...@pobox.com> wrote:

>Jeremy Russell <jeremy....@usa.net> wrote:
>> Thanks for the info - is there no corresponding mechanism in Jserv
>> then?
>
>I don't know, to be honest - I don't believe so. Any reason not to
>upgrade to Tomcat?

I guess not - just nervous about breaking what I do have working. But
I'm trying to figure out how to upgrade now ...

Jeremy Russell

unread,
Mar 7, 2002, 4:04:30 PM3/7/02
to

I'm downloading a JSDK 1.3 and Tomcat 4.0 - hopefully, that's gonna do
it. Am I correct in thinking that I need to install the JDK, then
Tomcat - stop my Apache service and start the Tomcat? In that order?

Jeremy

Chris Smith

unread,
Mar 7, 2002, 5:17:57 PM3/7/02
to
Jeremy Russell wrote ...

> I'm downloading a JSDK 1.3 and Tomcat 4.0 - hopefully, that's gonna do
> it. Am I correct in thinking that I need to install the JDK, then
> Tomcat - stop my Apache service and start the Tomcat? In that order?

Sure, but the upgrade is a bit more complicated than that. JServ and
Tomcat provide considerably different environments: JServ's is an ad hoc
kind of thing that relates specifically to that container, whereas Tomcat
provides the standard 2.2 servlet web application environment. As a
result, all your servlet "zone" configuration, the /servlet/* URLs, and
the like will no longer apply. Instead, you'll have a WEB-INF/web.xml
file in your web application that maps servlets to URLs.

The Servlet API itself is pretty much backward-compatible, though version
2.1 deprecated and intentionally broke several features... if you compile
against a newer version of the API, you'll get deprecation warnings if
you use these. (They aren't particularly useful, so it's doubtful that
you do).

Chris Smith

Jon Skeet

unread,
Mar 7, 2002, 5:27:20 PM3/7/02
to
Jeremy Russell <jeremy....@usa.net> wrote:
> I'm downloading a JSDK 1.3 and Tomcat 4.0 - hopefully, that's gonna do
> it. Am I correct in thinking that I need to install the JDK, then
> Tomcat - stop my Apache service and start the Tomcat? In that order?

Stop *everything*, install the JDK, then get Tomcat working *without*
Apache. Then work out how to connect up Apache to Tomcat afterwards.

Jeremy Russell

unread,
Mar 7, 2002, 5:51:16 PM3/7/02
to
On Thu, 7 Mar 2002 15:17:57 -0700, Chris Smith <cds...@twu.net>
wrote:

OK, I'm working on getting my brain around this, but would appreciate
a little more help on getting this setup right.

Does Tomcat standalone serve both HTML and servlet purposes? If so,
why would I need Apache with embedded Tomcat?

My brain hurts ...

Luke Webber

unread,
Mar 7, 2002, 5:52:29 PM3/7/02
to
"Jon Skeet" <sk...@pobox.com> wrote in message
news:MPG.16f1bbd58...@dnews.peramon.com...
[snip]

> Nope, that gives a clue as to the verison of the servlet API you're
> *compiling* against. That may or may not be the same as your actual
> runtime servlet engine.
[snip]

> So, you're using JServ at runtime. JServ only implements v2.0 of the
> servlet API, which doesn't have ServletContext.getRequestDispatcher.
> You'll either have to not use it, or change servlet engine.

FWIW, I always try to ensure that I compile against the servlet.jar file
from the servlet engine that I'm using. That may not be practical in all
cases, but it could certainly save a lot of confusion if Jeremy could manage
it.

Luke


Jeremy Russell

unread,
Mar 7, 2002, 6:14:48 PM3/7/02
to
On Thu, 07 Mar 2002 22:52:29 GMT, "Luke Webber" <lu...@webber.com.au>
wrote:

And Jeremy's gonna try - if'n this stuff EVER downloads :(

I actually thought I was using the same JAR file and it was only when
this all started that I determined I was wrrrr... I was wrrrrooo ... I
wasn't correct in that assumption.

Cheers, Luk

Jeremy Russell

unread,
Mar 7, 2002, 6:15:57 PM3/7/02
to
On Thu, 07 Mar 2002 22:52:29 GMT, "Luke Webber" <lu...@webber.com.au>
wrote:

>"Jon Skeet" <sk...@pobox.com> wrote in message

Whoa - that was Freudian - for "Luk" in the previous message, read
"Luke".

Chris Smith

unread,
Mar 7, 2002, 6:18:18 PM3/7/02
to
Jeremy Russell wrote ...

> OK, I'm working on getting my brain around this, but would appreciate
> a little more help on getting this setup right.
>
> Does Tomcat standalone serve both HTML and servlet purposes? If so,
> why would I need Apache with embedded Tomcat?

It does do both, and you don't need Apache... unless you want access to
advanced features of Apache that Tomcat doesn't provide.

Chris Smith

Jon Skeet

unread,
Mar 7, 2002, 6:24:27 PM3/7/02
to
Jeremy Russell <jeremy....@usa.net> wrote:

> OK, I'm working on getting my brain around this, but would appreciate
> a little more help on getting this setup right.
>
> Does Tomcat standalone serve both HTML and servlet purposes?

Yup.

> If so, why would I need Apache with embedded Tomcat?

Apache will generally be more efficient than Tomcat for static content,
and you can then use its various other modules.

On the other hand, if Tomcat does all you need it to, feel free to stick
just to Tomcat.

Jeremy Russell

unread,
Mar 7, 2002, 6:42:23 PM3/7/02
to
Once again, Chris, John, Luke - thanks - and don't you guys ever
sleep? 35% done with the downloading - 3h:54m to go

Marshall Spight

unread,
Mar 8, 2002, 1:54:15 AM3/8/02
to
"Jon Skeet" <sk...@pobox.com> wrote in message news:MPG.16f20705f...@dnews.peramon.com...

> Apache will generally be more efficient than Tomcat for static content,
> and you can then use its various other modules.

True, but neither one is particularly impressive in the performance department.
Not that it matters if you have fewer than 10e6 requests/day.


Marshall

0 new messages