felgen
asked on
servlets with netscape fasttrack server
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/netscap e/NSRunner " vpath="/servlet" initfile="C:/Netscape/Serv er/httpd-m om/config/ servlets.p roperties"
</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.
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/netscap
</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.
ASKER
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/netscap e/NSRunner " vpath="/servlet" initfile="C:/Netscape/Serv er/httpd-m om/config/ servlets.p roperties"
</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.NSRun ner" from a directory that holds the
structure sun/servlet/...
I've got a "class sun/servlet/netscape/NSRun ner 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.
In the obj.conf file I've edited
<Object name="servlet">
Service fn="java-run" class="sun/servlet/netscap
</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.NSRun
structure sun/servlet/...
I've got a "class sun/servlet/netscape/NSRun
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.
You reasoning seems OK. If a class is corrupted, a "Class not found" appears indeed at the console.
ASKER
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/h tml");
ServletOutputStream out = res.getOutputStream();
out.println("<html><head>< title>Too big</title></head>");
out.println("<body><h1>"+d ummy2+"Err or - content length >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.get OutputStre am());
outStream.println("hello") ;
outStream.close();
DataInputStream inStream = new DataInputStream(connection .getInputS tream());
while ((inputLine = inStream.readLine()) != null) {
dummy+=inputLine;
}
inStream.close();
repaint();
} catch (MalformedURLException me) {
System.err.println("Malfor medURLExce ption: " + me);
} catch (IOException ioe) {
System.err.println("IOExce ption: " + ioe);
}
}
when I use the servletrunner it works, but using the fasttrack server I got IOException: java.net.SocketException: uneexpected EOF
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/h
ServletOutputStream out = res.getOutputStream();
out.println("<html><head><
out.println("<body><h1>"+d
out.println("</h1></body><
}
communcates with an applet:
try {
URL url = new URL("http://mom.schoue.com/servlet/TestServlet");
URLConnection connection = url.openConnection();
PrintStream outStream = new PrintStream(connection.get
outStream.println("hello")
outStream.close();
DataInputStream inStream = new DataInputStream(connection
while ((inputLine = inStream.readLine()) != null) {
dummy+=inputLine;
}
inStream.close();
repaint();
} catch (MalformedURLException me) {
System.err.println("Malfor
} catch (IOException ioe) {
System.err.println("IOExce
}
}
when I use the servletrunner it works, but using the fasttrack server I got IOException: java.net.SocketException: uneexpected EOF
ASKER
I getting the error when I try to get the Datainputstream
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That does'nt work either.
ASKER
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
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
I remember a bad joke. Try flushing your ServletOutputStream.
ASKER
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?
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?
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
http://jserv.javasoft.com
ASKER
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.
Through an URLConnection?
That will not work because I don't know
the Address from where the Applet will make
the connection.
> 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/h tml");
ServletOutputStream out = res.getOutputStream();
out.println("<html><head>< title>Too big</title></head>");
out.println("<body><h1>"+d ummy+"Erro r - content length >8k not ");
out.println("</h1></body>< /html>");
out.flush();
Via the ServletInputStream...which
ServletInputStream in = req.getInputStream();
DataInputStream inStream = new DataInputStream(in);
String dummy = inStream.readLine();
res.setContentType("text/h
ServletOutputStream out = res.getOutputStream();
out.println("<html><head><
out.println("<body><h1>"+d
out.println("</h1></body><
out.flush();
ASKER
Now everything is fine.
Even the MS IE can communicate with the servlet over
the https protocol.
Thanks for your help!
Even the MS IE can communicate with the servlet over
the https protocol.
Thanks for your help!
> 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.
> 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.
"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.