Dear Friends,
I am stuck in this error and would appreciate if someone could help me in
this:-
Here , I am trying to post a request to google spell check feature and then
obtaining the XML file with results.
However, I am getting a connect time out error on this code..
Code
----------
<%@ page language = "java" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.io.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.net.*" %>
<%@ page import="java.nio.*" %>
<%@ page import="com.google.gwt.language.*" %>
<%@ page import="com.google.gwt.user.*" %>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="UTF-8" %>
<%
try
{
out.println("Hello");
Properties systemSettings = System.getProperties();
systemSettings.put("http.proxyHost", "***********");
systemSettings.put("http.proxyPort", "**");
systemSettings.put("sun.net.client.defaultConnectTimeout", "10000");
systemSettings.put("sun.net.client.defaultReadTimeout", "10000");
out.println("Properties Set");
Authenticator.setDefault(new Authenticator()
{
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("*****",
"******".toCharArray()); // specify ur user name password of iitb login
}
});
System.setProperties(systemSettings);
out.println("After Authentication & Properties Settings");
//create xml file.
//the input to google api
//String textAreaContent = request.getParameter("text");
String textAreaContent = "This si a tst";
String str = "<?xml version='1.0' encoding='utf-8' ?>";
str = str + "<spellrequest textalreadyclipped='0' ignoredups='0'
ignoredigits='1' ignoreallcaps='1'>";
str = str + "<text> " + textAreaContent + "</text>";
str = str + "</spellrequest>";
//xml file generation ends here..
URL url = new URL("https://www.google.com/tbproxy/spell?lang=en&hl=en");
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
//pass paramet...@xml file..
OutputStreamWriter outsw = new
OutputStreamWriter(connection.getOutputStream());
outsw.write(str);
outsw.close();
//parameters passed
BufferedReader in = new BufferedReader( new InputStreamReader(
connection.getInputStream()));
String decodedString;
String tempstr = "";
while ((decodedString = in.readLine()) != null)
{
tempstr = tempstr + decodedString;
}
out.println(tempstr);
in.close();
}
catch(Exception ex)
{
out.println("Exception->"+ex);
PrintWriter pw = response.getWriter();
ex.printStackTrace(pw);
}
%>
---------
Error Message:-
----------------------------
java.net.SocketTimeoutException: connect timed out at
java.net.PlainSocketImpl.socketConnect(Native Method) at
java.net.PlainSocketImpl.doConnect(Unknown Source) at
java.net.PlainSocketImpl.connectToAddress(Unknown Source) at
java.net.PlainSocketImpl.connect(Unknown Source) at
java.net.Socket.connect(Unknown Source) at
sun.net.NetworkClient.doConnect(Unknown Source) at
sun.net.www.http.HttpClient.openServer(Unknown Source) at
sun.net.www.http.HttpClient.openServer(Unknown Source) at
sun.net.www.protocol.https.HttpsClient.(Unknown Source) at
sun.net.www.protocol.https.HttpsClient.New(Unknown Source) at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown
Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown
Source) at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown
Source) at
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown
Source) at
org.apache.jsp.googiespellchecker_jsp._jspService(googiespellchecker_jsp.java:112)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Unknown Source) Hello Properties Set After
Authentication & Properties Settings
Exception->java.net.SocketTimeoutException: connect timed out
----------------------------
Looking forward for your reply.
Regards,
Jitesh Dundas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---