A
anu
Hi all,
I am doing a web application.in that i have comnnected from a java
class to the servlet using URLConnection APIs.The problem now i am
facing is i need to return some values from the servlet to the calling
javaclass.how can i do this?
I have used the following code.
In the javaclass...
String location = "http://localhost:8080/Scroll_Sample/ScrollServlet?
param1="+username+"¶m2="+password;
URL testServlet = new URL(location);
URLConnection servletConnection =
testServlet.openConnection();
InputStream instr = servletConnection.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
String name1 = (String)inputFromServlet.readObject();
System.out.println("name is "+name1);
System.out.println("contenttype is
"+servletConnection.getContentType());
System.out.println("within end of try");
And in the servlet............................
response.setContentType("application/x-java-serialized-object");
OutputStream outstr = response.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstr);
String name1="anu";
oos.writeObject(name1);
The exception i have got is
Within try
Exception isjava.io.IOException: Server returned HTTP response code:
500 for URL: http://localhost:8080/Scroll_Sample/ScrollServlet?param1=anu¶m2=anu
java.io.IOException: Server returned HTTP response code: 500 for URL:
http://localhost:8080/Scroll_Sample/ScrollServlet?param1=anu¶m2=anu
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:
1149)
at ServletConnect.main(ServletConnect.java:61)
can anyone suggest any idea pls?
Thanks in Advance.....
I am doing a web application.in that i have comnnected from a java
class to the servlet using URLConnection APIs.The problem now i am
facing is i need to return some values from the servlet to the calling
javaclass.how can i do this?
I have used the following code.
In the javaclass...
String location = "http://localhost:8080/Scroll_Sample/ScrollServlet?
param1="+username+"¶m2="+password;
URL testServlet = new URL(location);
URLConnection servletConnection =
testServlet.openConnection();
InputStream instr = servletConnection.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
String name1 = (String)inputFromServlet.readObject();
System.out.println("name is "+name1);
System.out.println("contenttype is
"+servletConnection.getContentType());
System.out.println("within end of try");
And in the servlet............................
response.setContentType("application/x-java-serialized-object");
OutputStream outstr = response.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstr);
String name1="anu";
oos.writeObject(name1);
The exception i have got is
Within try
Exception isjava.io.IOException: Server returned HTTP response code:
500 for URL: http://localhost:8080/Scroll_Sample/ScrollServlet?param1=anu¶m2=anu
java.io.IOException: Server returned HTTP response code: 500 for URL:
http://localhost:8080/Scroll_Sample/ScrollServlet?param1=anu¶m2=anu
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:
1149)
at ServletConnect.main(ServletConnect.java:61)
can anyone suggest any idea pls?
Thanks in Advance.....