cancel
Showing results for 
Search instead for 
Did you mean: 

How to open a browser in "ServerSide" automatically and set url using java

Former Member
0 Kudos

hai

my problem is to run a servlet in serverside automatically.

i have to open a browser in serverside and execute a servlet .

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi, I think you are trying to call an url in backgound, aren't you?

This code is very cool :

// begin

try {

// Construct data

String data = URLEncoder.encode("key1", "UTF-8") + "=" + URLEncoder.encode("value1", "UTF-8");

data += "&" + URLEncoder.encode("key2", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");

// Send data

URL url = new URL("http://hostname:80/cgi");

URLConnection conn = url.openConnection();

conn.setDoOutput(true);

OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());

wr.write(data);

wr.flush();

// Get the response

BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));

String line;

while ((line = rd.readLine()) != null) {

// Process line...

}

wr.close();

rd.close();

} catch (Exception e) {

}

// end

[]s

Renato.

Former Member
0 Kudos

hi bojja,

The fallowing pdf file (page no. 111 to 117) will give you more info. about execution of servlet.

hope this will solve your problem , ple reward the points soon.

http://java.sun.com/j2ee/sdk_1.2.1/devguide1_2_1.pdf

Thanks,

Varun

Message was edited by: Varun Kumar C N