You can compile your existing code using the following command:
javac -deprecation <file name>
compile and enjoy servlets, OK
Main Topics
Browse All Topics
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class t2 extends HttpServlet {
public void doGet (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/h
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec( new String[] { "netstat -rn" } );
DataInputStream in = new DataInputStream( process.getInputStream() );
PrintWriter com_out = res.getWriter();
com_out.println("<pre>");
String line = null;
while ( ( line = in.readLine() ) != null ) {
com_out.println( line );
}
}
}
Hi,
I compile the servlet above and receive the below
error. Can someone help me fix the problem?
thanks in advance.
t2.java:16: Note: The method java.lang.String readLine() in class java.io.DataInputStream has been deprecated.
while ( ( line = in.readLine() ) != null ) {
^
Note: t2.java uses or overrides a deprecated API. Please consult the documentation for a better alternative.
1 warning
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I successfully compile, but I got these errors when run
it from the netscape browser:
[05/Dec/2001:10:51:05] failure (13631): Internal error: exception thrown from the servlet service function (uri=/servlet/t2.class): java.io.IOException: netstat -rn: not found, Stack: java.io.IOException: netstat -rn: not found
at java.lang.UNIXProcess.fork
at java.lang.UNIXProcess.<ini
at java.lang.Runtime.execInte
at java.lang.Runtime.execInte
at java.lang.Runtime.exec(Com
at java.lang.Runtime.exec(Com
at t2.doGet(Compiled Code)
at javax.servlet.http.HttpSer
at javax.servlet.http.HttpSer
at com.iplanet.server.http.se
at com.iplanet.server.http.se
Business Accounts
Answer for Membership
by: objectsPosted on 2001-12-04 at 17:39:49ID: 6666563
Yes if you check the javadoc you'll see that the readLine method has been deprecated.
It's only a warning so your code will still have gotten compiled.
To get rid of the warning, replace the use of DataInputStream with a BufferedReader.