Corporate Info | News | Solutions | Products | Partners | Services | Events | Download | How To Buy
Frequently Asked Questions: Previous topic | Next topic | Contents

WebLogic Frequently Asked Questions: Server-side Java (Servlets)

- Using Java servlets with various webservers

- Can I use WebLogic's JDBC drivers with Netscape servers?

- How do I call a servlet with parameters in the URL?

- Can't connect to database with the Java WebServer and an HTTP servlet

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 JDBC drivers with Netscape servers?

I'm trying to use Netscape Enterprise Server with WebLogic jDriver for Oracle. My servlets will not work.

There are problems in Netscape servers using Java classes with native methods, such as our type 2 JDBC driver WebLogic jDriver for Oracle. 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 WebLogic jDriver JDBC 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?

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
      }

Can't connect to database with the Java WebServer and an HTTP servlet

I'm using the JavaSoft Java WebServer, and I can't get my HTTP servlets, which use the WebLogic jDriver for Oracle, 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 WebLogic jDriver for Oracle JDBC driver, 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 WebLogic 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:

1. Change directories (cd) into the weblogic/classes directory.

2. 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.

3. Place the .zip or .jar file into the directory JavaWebServer1.0.1/lib.

4. 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. 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 web server.

If you choose to use 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 WebLogic Server as an HTTP server, or the Java WebServer FAQ at JavaSoft.

Copyright © 2000 BEA Systems, Inc. All rights reserved. Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.