Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

servlets with netscape fasttrack server

Posted on 1998-04-08
15
251 Views
Last Modified: 2013-11-24
I have a problem configuring netscapes fasttrack server
to use servlets.
I' ve followed the instructions from the jsdk developer kit:

- I enabled java for the server
- I've made the following changes in the obj.conf file:

      NameTrans from="/servlet" fn="pfx2dir" dir=C:/Jsdk/servlets name="servlet"

      <Object name="servlet">

   Service fn="java-run" class="sun/servlet/netscape/NSRunner" vpath="/servlet" initfile="C:/Netscape/Server/httpd-mom/config/servlets.properties"

</Object>

I've requested a servlet with:

http://host/servlet/SimpleServlet 

and got a Not Found error.

I've tried to run the servlet with the servletrunner and it works.

What went rong.
0
Comment
Question by:felgen
  • 8
  • 7
15 Comments
 
LVL 5

Expert Comment

by:fontaine
ID: 1233966
Depending on the version of FastTrack you use, it is possible that JDK 1.1 is not supported. At the end of README.netscape in the JSDK, it is indeed written:

"2. The servlets run under Netscape's VM.  This means all servlets _must_
   be compiled with the 1.0.2 version of the JDK, and use only 1.0.2 classes.
   For information on when Netscape will support 1.1 in their server VM,
   please contact Netscape."

It is probable that the sample servlets of JSDK have been compiled with JDK 1.1.
0
 

Author Comment

by:felgen
ID: 1233967
I've recompiled the HelloWorldServlet under jdk 1.0.2 with no success. I think the problem is how the servlet is started.
In the obj.conf file I've edited

<Object name="servlet">

   Service fn="java-run" class="sun/servlet/netscape/NSRunner" vpath="/servlet" initfile="C:/Netscape/Server/httpd-mom/config/servlets.properties"

</Object>

This should start java executing NSRunner when I use this URL

http://host/servlet/SimpleServlet 

I believe this execution of NSRunner doesn't work and the browser
can't resolve the URL giving me the Not Found error.

I've tried to start NSRunner from console with "java sun.servlet.netscape.NSRunner" from a directory that holds the
structure sun/servlet/...
I've got a "class sun/servlet/netscape/NSRunner not found" error
I've tried the same with NSResponse and this class was found.
So I think there is a problem with NSRunner.

Correct me if you think I am rong.


0
 
LVL 5

Expert Comment

by:fontaine
ID: 1233968
You reasoning seems OK. If a class is corrupted, a "Class not found" appears indeed at the console.
0
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 

Author Comment

by:felgen
ID: 1233969
Now it works!!
The obj.conf file was not properly loaded.
But now I have the next problem.
My testservlet, here is a part of it:

public void doPost (HttpServletRequest req, HttpServletResponse res)

      throws ServletException, IOException

    {

        byte[] dummy = new byte[1024];

       

        ServletInputStream in = req.getInputStream();

        in.readLine(dummy,0,1024);

        String dummy2 = new String(dummy);

          res.setContentType("text/html");

        ServletOutputStream out = res.getOutputStream();

          out.println("<html><head><title>Too big</title></head>");

          out.println("<body><h1>"+dummy2+"Error - content length &gt;8k not ");

          out.println("</h1></body></html>");



    }

communcates with an applet:

try {

                           URL url = new URL("http://mom.schoue.com/servlet/TestServlet");

                           URLConnection connection = url.openConnection();



                           PrintStream outStream = new PrintStream(connection.getOutputStream());

                           outStream.println("hello");

                           outStream.close();

                           

                           DataInputStream inStream = new DataInputStream(connection.getInputStream());



                           while ((inputLine = inStream.readLine()) != null) {

                               dummy+=inputLine;

                           }

                           inStream.close();

                           repaint();

                       } catch (MalformedURLException me) {

                           System.err.println("MalformedURLException: " + me);

                       } catch (IOException ioe) {

                           System.err.println("IOException: " + ioe);

                       }



      }

when I use the servletrunner it works, but using the fasttrack server I got IOException: java.net.SocketException: uneexpected EOF

0
 

Author Comment

by:felgen
ID: 1233970
I getting the error when I try to get the Datainputstream
0
 
LVL 5

Accepted Solution

by:
fontaine earned 100 total points
ID: 1233971
Here, you are performing a POST operation. So, you have to indicate that you want to send data through the connection by adding a connection.setDoOutput(true) just after:

URLConnection connection = url.openConnection();
0
 

Author Comment

by:felgen
ID: 1233972
That does'nt work either.
0
 

Author Comment

by:felgen
ID: 1233973
I've got the error IOException: java.net.SocketException:
       uneexpected EOF
when I debug the Applet with visualcafe.
Running the Applet within a browser I'm getting the error
IOException: java.io.IOException: document contains no data
0
 
LVL 5

Expert Comment

by:fontaine
ID: 1233974
I remember a bad joke. Try flushing your ServletOutputStream.
0
 

Author Comment

by:felgen
ID: 1233975
I've compiled my TestServlet under jdk 1.1 and used the constructor

String dummy2 = new String(dummy);

As you pointed out Netscapes VM supports only jdk 1.0.2.
So I have to use

String(byte[] dummy,int hibyte);

which value is the right one for hibyte?
Do you know a debugger for servlets?

0
 
LVL 5

Expert Comment

by:fontaine
ID: 1233976
Why don't you use a DataInputStream also in the servlet? Your code would be more symetric (and your problem to convert a byte array to a String would be solved too). You should maybe look for an update of your server because now JDK 1.1 is supported by FastTrack. I don't know if there is a debugger for servlets. If there is, it is at the following site:

http://jserv.javasoft.com
0
 

Author Comment

by:felgen
ID: 1233977
How do I get the DataInputstream?
Through an URLConnection?
That will not work because I don't know
the Address from where the Applet will make
the connection.
0
 
LVL 5

Expert Comment

by:fontaine
ID: 1233978
> How do I get the DataInputstream?

Via the ServletInputStream...which is an InputStream. Your doPost() becomes:

ServletInputStream in = req.getInputStream();
DataInputStream inStream = new DataInputStream(in);
String dummy = inStream.readLine();

res.setContentType("text/html");
ServletOutputStream out = res.getOutputStream();
out.println("<html><head><title>Too big</title></head>");
out.println("<body><h1>"+dummy+"Error - content length &gt;8k not ");
out.println("</h1></body></html>");
out.flush();
0
 

Author Comment

by:felgen
ID: 1233979
Now everything is fine.
Even the MS IE can communicate with the servlet over
the https protocol.
Thanks for your help!
0
 
LVL 5

Expert Comment

by:fontaine
ID: 1233980
> Even the MS IE can communicate with the servlet over
> the https protocol.

Yes, that's what I added as a comment to your other question. Oh, you just graded! Huuum, thanks for the grades...and good luck for your development.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet filter example 37 71
ejb stateless example 2 23
Desingning Refactoring existing code 2 26
junit as external jar or library 7 22
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question