0

Hi!

I'm trying to run a servlet from Java program. This servlet would then open a JSP page in browser. The problem is that the contents of the jsp file is showed in Eclipse console, but it doesn't show in Firefox. Could you help me plz? Sorry for my bad English:)

My code looks like this:

String request = "test";
java.net.URL netUrl = new java.net.URL(http://localhost:8080/myservlet);
connection = (HttpURLConnection) netUrl.openConnection();
connection.setRequestMethod( "POST" );
connection.setRequestProperty("Content-Length", "" +
Integer.toString(request.getBytes().length));
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
DataOutputStream out = new DataOutputStream( connection.getOutputStream() );
out.writeBytes( request );
out.flush();
out.close();
BufferedReader reader = new BufferedReader( new InputStreamReader(
connection.getInputStream() ) );
String response = reader.readLine();
while( null != response )
{
System.out.println( response );
response = reader.readLine();
}

Best regards,
Goran

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by ~s.o.s~
0
public class FireFox {
    public static void main(String args[]) throws IOException {
        Runtime run = Runtime.getRuntime();
        String url = "http://localhost:8080/myservlet/";
        String ff = "your-path-to-firefox/firefox";
        String command = ff + " " + url;
        run.exec(command);
        System.exit(0);
    }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.