How do I get a cookie from an external website?

I'm looking for help with something like this: I have website A on which i set Cookie. In this same browser o opened website B and i'm trying to connect from website B to website A using code: > String responseSession = ""; try { URL url = new URL(urlSCS + "session" ); InputStream response = url.openStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(response, "UTF-8")); for(String line; (line = reader.readLine()) != null;){ responseSession += line; } }catch(Exception e){ e.printStackTrace(); } return responseSession; to get the Cookie from website A. The problem is that, when i open site A with Cookie the cookie displays correct, but when i'm trying to get the cookie by website B i get error: > SEVERE: Servlet.service() for servlet appServlet threw exception java.lang.NullPointerException at com.esb.scs.SessionController.session( at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke( at sun.reflect.DelegatingMethodAccessorImpl.invoke( at java.lang.reflect.Method.invoke( at at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod( at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle( at org.springframework.web.servlet.DispatcherServlet.doDispatch( at org.springframework.web.servlet.DispatcherServlet.doService( at org.springframework.web.servlet.FrameworkServlet.processRequest( at org.springframework.web.servlet.FrameworkServlet.doGet( at javax.servlet.http.HttpServlet.service( at javax.servlet.http.HttpServlet.service( at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( at org.apache.catalina.core.ApplicationFilterChain.doFilter( at at org.springframework.web.filter.OncePerRequestFilter.doFilter( at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( at org.apache.catalina.core.ApplicationFilterChain.doFilter( at org.apache.catalina.core.StandardWrapperValve.invoke( at org.apache.catalina.core.StandardContextValve.invoke( at org.apache.catalina.core.StandardHostValve.invoke( at org.apache.catalina.valves.ErrorReportValve.invoke( at org.apache.catalina.core.StandardEngineValve.invoke( at org.apache.catalina.connector.CoyoteAdapter.service( at org.apache.coyote.http11.Http11Processor.process( at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process( at$ at
The other thing is - don't keep posting the same question over and over again. This is three times now. At least close your old questions. You're making a mess.

以上就是How do I get a cookie from an external website?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准