Execute A Jsp Program On Background Of A Running Java Program
I just want execute my jsp program when a button on my running java program is clicked, it doesn't need to be visible, the jsp program i am saying is for printing and once it is lo
Solution 1:
this should be working , cant be sure if it serves properly , please assure me the outcome
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
publicclasscallURL {
publicstaticvoidmain(String[] args)
{
Stringurl="http://localhost:8080/OpenID/asd.html";
HttpClienthttpClient=newDefaultHttpClient();
HttpPosthttpPost=newHttpPost(url);
HttpResponse response;
StringBuilder builder= newStringBuilder();
try
{
response = httpClient.execute(httpPost);
BufferedReaderin=newBufferedReader(newInputStreamReader(response.getEntity().getContent(), "UTF-8"));
char[] buf = newchar[8000];
intl=0;
while (l >= 0)
{
builder.append(buf, 0, l);
l = in.read(buf);
}
}
catch (ClientProtocolException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
for this java program to ececute your jsp
you have to add this line in your jsp page
<script>window.location.href="http://localhost:8080/OpenID/asd.html"</script>
where OpenId : Application Name
asd.html is your jsp page , the same jsp which you are calling from java program
Post a Comment for "Execute A Jsp Program On Background Of A Running Java Program"