FAQ Index
Using Java servlets with various webservers
We're writing Java servlets
as a significant portion of our online web application
suite. At the moment, we're using a Netscape server, but we have been
investigating other possibilities. What webservers currently support
standard Java servlets?
Using Java servlets is a pretty safe bet for the near future, since
support for the JavaSoft standard Java Servlet API is increasing.
However, there are still a few considerations. Microsoft IIS does not
currently support Java servlets, and is not likely to do so anytime
soon since servlets compete with their Active Server Pages
technology. Netscape servers support Java servlets, using a
plug-in. Java Web Server also supports servlets. JavaSoft's Java
Servlet Development Kit (JSDK) contains a plug-in that enables
servlets in IIS 2.0 and 3.0. JavaSoft has a page devoted to JSDK that lists some other options as
well.
Of course, WebLogic supports servlet requests and transparently
proxies any other HTTP
requests to whatever webserver your customers are using,
including IIS. And one advantage of WebLogic's servlet support is that
your servlets also have access to all of WebLogic's other services,
including EJB
, RMI
, and JDBC
.
Can I use WebLogic's database drivers with Netscape servers?
I'm trying to use Netscape's Enterprise Server with WebLogic's
two-tier drivers for server-side Java. My servlets will not work.
There are problems in Netscape servers using Java classes with native
methods (such as our jdbcKona
type 2 drivers). If you want to access a database from a Netscape server
using our drivers, you must use our three-tier driver (WebLogic JDBC
)
or one of our Type 4 two-tier
drivers for Informix and Microsoft SQL Server, both of which are pure
Java. The jdbcKona drivers can work with WebLogic JDBC to access the
database and then communicate with the Netscape server using pure
Java. For more information about the multitier driver, see Using WebLogic JDBC.
How do I call a servlet with parameters in the URL?
How do I call a servlet with parameters in the URL, and then how do
I use the parameters in the servlet? Do I need WebLogic Remote
to use servlets with the WebLogic Server?
The usual format of a servlet
parameter is a name=value pair that comes after a question-mark
(?) at the end of the URL
. For Jeeves-style servlets, you filter the parameters by
calling the getParameter()
method on the HttpServletRequest object, then write code to test the
strings. For example, if your URL parameters are "func=topic", where
your URL appears as:
http://www.myserver.com/myservlet?func=topic
then you could parse the parameter as follows, where "req" is
the HttpServletRequest object:
String func = req.getParameter("func");
if (func.equalsIgnoreCase("topic")) {
. . . do some work
}
You do need WebLogic Remote to use either Java Servlet API HTTP
servlets or WebLogic T3Servlets with the WebLogic Server. There are
examples of both types of servlets in the examples/htmlkona and examples/servlets directories in the distribution.
Can't connect to database with the Java WebServer and an HTTP servlet
I'm using JavaSoft's Java WebServer, and I can't get my HTTP servlets,
which use the jdbcKona drivers, to work. I've configured my server to
find the WebLogic classes, but the servlets still do not work.
There is a known problem with the servlet
classloader in the Java WebServer that prevents it from being able to
load classes containing native code. Servlets containing classes using
native methods, such as the jdbcKona
drivers, will not work with the Java WebServer. There are, however,
two possible solutions: modify how you load the WebLogic classes with
your Java WebServer, or (even easier) use WebLogic as your webserver.
Here is how to change how you load the WebLogic classes when using
servlets and the Java WebServer with a jdbcKona driver. You will need
to create a "classes.zip" or a "classes.jar" file that contains the
WebLogic classes, and then place it in the proper directories on your
Java WebServer host. Here is how:
- Change directories (cd) into the weblogic/classes directory.
- Enter this command at the prompt to create a .zip file:
$ zip -r classes.zip *
Or use the Jar tool (jar.exe) that comes with the JDK
distribution
to create a classes.jar file.
- Place the .zip or .jar file into the directory JavaWebServer1.0.1/lib.
- Put the WebLogic .dlls (for example, weblogicoci23.dll) into the directory JavaWebServer1.0.1/bin. Make sure
that the DBMS and system libraries are also in the Java WebServer's
PATH.
An easier solution is to use the WebLogic Server to serve your
servlets. The WebLogic Server supports Java-Server-API (HTTP)
servlets and its classloader allows loading of classes containing
native methods. You can serve some or all of your servlets using the
WebLogic Server and proxy other HTTP
requests to another webserver.
If you choose to use the WebLogic Server to serve your servlets, note
that servlets using native methods that are not part of the
WebLogic software will fail with an "Unsatisfied Link" error if they
are placed in the servlet CLASSPATH
. Be sure not to put classes containing native methods in
the servlet CLASSPATH. Instead, put these servlets in the regular
CLASSPATH of the WebLogic Server.
For more information, see
Setting up the WebLogic Server as an
HTTP server, or the Java
WebServer FAQ at JavaSoft.
