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

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);
    }
}