on 01-31-2006 5:39 AM
hai
my problem is to run a servlet in serverside automatically.
i have to open a browser in serverside and execute a servlet .
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
26 | |
10 | |
9 | |
7 | |
6 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.