URL,URLConnection,HttpURLConnection &&Session

Hi,all
I want to access a web page by URL/URLConnection/HttpURLConnection
the page need a login user,it check the Session,if the session is null,then it redirect to the login page
Now I have the user ID and Password ,and I can complete my login by URL Class
but when I access the wanted page after I login,it's still return that the session is not set.
below is the Code Segment,thanx in advance
String urlStr = "http://buyc:8080/ecommerce/oa/login.jsp?txtUsername=sh001&txtPwd=111111&role=storeman";
URL url = new URL(urlStr);
HttpURLConnection hurlc =(HttpURLConnection) url.openConnection();
hurlc.setFollowRedirects(true);
hurlc.setInstanceFollowRedirects(true);
hurlc.setUseCaches(true);
hurlc.connect();//if check login successfully in login.jsp,it will redirect to a check page.
InputStream is=hurlc.getInputStream();//
byte tmpbyte[]=new byte[is.available()];
int num=is.read(tmpbyte);
String result=new String(tmpbyte);
System.out.println("the " + num + ":" + result);

IIRC, you use the UrlConnection's methods getHeaderField and getHeaderFields to get the cookies, and then setRequestProperty to set the cookies on subsequent connections. These methods are inherited by HttpUrlConnection.
There may be a library out there to make this stuff easier, but I don't think it's in the standard libraries.

Similar Messages

  • About UrlConnection and session

    Hi,
    here
    String urlString = "http://192.168.0.139:8080/Customize/setCredentials";
    URL url = new URL(urlString);
    HttpURLConnection hpcon = (HttpURLConnection) url.openConnection();
    this will establish a connection with the username and password.
    after this i need to communication with another servlet..
    String urlString1 = "http://192.168.0.139:8080/Customize/AddData";
    URL url1 = new URL(urlString1);
    HttpURLConnection hpcon 1= (HttpURLConnection) url.openConnection();
    if i do this its again asking for credenstials..
    how can i use tjhe session info from above connection..
    mean can i set this url string to the above logged in connection..
    regards,

    Hi,
    Iam not doing anything to keep the sessiions..everything inside that servlets which come software..i cannot manipulate that code.when iam using the microsftvar xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    var xml_dom = new ActiveXObject("MSXML2.DOMDocument");
    var xml_domTemp = new ActiveXObject("MSXML2.DOMDocument");
    with java script its working fine..after logginng iam getting the objects using the same urls.but when iam using the UrlConnection its giving the response that the usernotLogged in..
    regards,

  • URLConnection and sessions

    Hello all!
    I am writing a harness to test a web app. Part of the harness has to do HTTP
    connections and post some data to the web server. This is a part of a
    transaction load test...
    Here is working code for HTTP POST
    >>>>>
    try {
    URL url;
    URLConnection urlConn;
    DataOutputStream dos;
    DataInputStream dis;
    url = new URL(host);
    urlConn = url.openConnection();
    urlConn.setDoInput(true);
    urlConn.setDoOutput(true);
    urlConn.setUseCaches(false);
    urlConn.setRequestProperty("Content-Type",
    "application/x-www-form-urlencoded");
    java.net.HttpURLConnection con = (HttpURLConnection)url.openConnection();
    dos = new DataOutputStream(urlConn.getOutputStream());
    dos.writeBytes(post_data);
    dos.flush();
    dos.close();
    // Read out responce
    // Without this nothing works for some reason.
    dis = new DataInputStream(urlConn.getInputStream());
    dis.read();
    dis.close();
    // Done
    }catch(Exception oops){
    System.out.println(oops.getMessage());
    <<<<<
    POST works just fine, but the problem I run in to is that the connection
    requires sessions.
    Is there is a way to get a session from URLConnection.
    Or perhaps there is a better way of doing it.
    Any one knows?
    Thank you in advance. Your input is greatly appritiated.
    Alexander. (fliger) N.

    Did you ever complete your test harness and get it working.
    Ive been asked to build a test harness to make a number of connections to a http page (I think pretty close to your example).
    If it is working, do you mind posting me hte code to validate.
    [email protected]

  • Change url URLConnection

    I want to connect from an applet to a servlet with URLConnection. There are 2 ways to connect: in the beginning of each session you connect to the applet to get a list of drawn shapes. I create an URLConnection object and connect to the servlet. I go into the doGet-method, retrieve the values from a database and returns an arraylist. I use the doPost method to save new shapes.
    When i delete a shape from the canvas, i want to return to the doGet method by adding a parameter to the url. E.g ../ShapeServlet?shapeid=20. The problem is, the url is correct, but the URLConnection object keeps using the url from the beginning of the session (without the parameter). I use 2 seperate objects so it's kinda weird he keeps connecting to the servlet with the first url. I also tried to do it hard-coded, but it doesn't work either.
    Here's the code:
    Load the shapes from the applet:
         public ArrayList loadShapes()
              ObjectInputStream inputFromServlet = null;
              try{
                   URL servlet = new URL(url);
                   URLConnection con = servlet.openConnection();
                   con.setUseCaches(false);
                   inputFromServlet = new ObjectInputStream(con.getInputStream());
                   ArrayList lijst = (ArrayList) inputFromServlet.readObject();
                   inputFromServlet.close();
                   return lijst;
              catch(MalformedURLException e){ e.printStackTrace(); }
              catch(IOException e){ e.printStackTrace(); }
              catch(ClassNotFoundException e){ e.printStackTrace(); }
              return null;
         }Delete a shape:
         /** Shape weggooien */
         public void deleteShape(int shapeid)
              try{
                   String a = "http://PCPST2:8080/AppletViewer/ShapeServlet?shapeid=" + shapeid;
                   URL servlet = new URL(a);
                   System.out.println("DELETESHAPE: " + a);
                   URLConnection connectionTwo = servlet.openConnection();               
                   connectionTwo.setUseCaches(false);               
              catch(MalformedURLException e){ e.printStackTrace(); }
              catch(IOException e){ e.printStackTrace(); }
         }

    it seems that deleteShape() doesn't connect to the servlet. Is it possible that >the servlet rejects the connection?No, he simply doesnt connect :), wierd behaviour, but that's how the default implementation of URLConnection and HttpURLConnection works.
    The following is from javadocs
    The connection object is created by invoking the openConnection method on a URL.
    The setup parameters and general request properties are manipulated.
    The actual connection to the remote object is made, using the connect method.
    The remote object becomes available. The header fields and the contents of the remote object can be accessed.
    You havent used the connect() method in your deleteShapes() method.
    Hang on, even if you use it, it wouldnt connect to the Servlet.
    I did some reading up on this and again javadcos has this to say about the connect() method
    Operations that depend on being connected, like getContentLength, will implicitly perform the connection, if necessary.
    So what I did was forced connect() by getting the input stream from the connection.
    In your code, though the deleteShapes() method doesnt have anything to read from the Servlet, create a reader and make a dummy readLine() call.
    You would see that it connects now. Add the code below to your deleteShapes() method.
            InputStreamReader reader = new InputStreamReader(conn.getInputStream());       
            System.out.println((new BufferedReader(reader)).readLine());
             //this will return null, coz there's nothing to be read, and
             //yet it would ensure connection.Hope this helps,
    ram.

  • URL opens new session

    hi,
    I wrote some test client for testing my server. I create URL and call URL.getContent(). This open new session. But I want use one session. How I can use request for same session?
    <code>
    for (int i=0; i<10; i++)
    URL url = new URL(BASE_ADDRESS + "/adetail.jsf?fid=" + i);
    URLConnection connection = url.openConnection();
    // new session is created
    Object content = connection.getContent();
    </code>

    As i stated, when i click links from 3rd party applications, such as skype; a youtube link or something similar. Firefox opens a new session however it does not visit the clicked url

  • How to pass session variable value with GO URL to override session value

    Hi Gurus,
    We have below requirement.Please help us at the earliest.
    How to pass session variable value with GO URL to override session value. ( It is not working after making changes to authentication xml file session init block creation as explained by oracle (Bug No14372679 : which they claim it is fixed in 1.7 version  Ref No :Bug 14372679 : REQUEST VARIABLE NOT OVERRIDING SESSION VARIABLE RUNNING THRU A GO URL )
    Please provide step by step solution.No vague answers.
    I followed below steps mentioned.
    RPD:
    ****-> Created a session variable called STATUS
    -> Create Session Init block called Init_Status with SQL
        select 'ACTIVE' from dual;
    -> Assigned the session variable STATUS to Init block Init_Status
    authenticationschemas.xml:
    Added
    <RequestVariable source="url" type="informational"
    nameInSource="RE_CODE" biVariableName="NQ_SESSION.STATUS"/>
    Report
    Edit column "Contract Status" and added session variable as
    VALUEOF(NQ_SESSION.STATUS)
    URL:
    http://localhost:9704/analytics/saw.dll?PortalGo&Action=prompt&path=%2Fshared%2FQAV%2FTest_Report_By%20Contract%20Status&RE_CODE='EXPIRED'
    Issue:
    When  I run the URL above with parameter EXPIRED, the report still shows for  ACTIVE only. The URL is not making any difference with report.
    Report is picking the default value from RPD session variable init query.
    could you please let me know if I am missing something.

    Hi,
    Check those links might help you.
    Integrating Oracle OBIEE Content using GO URL
    How to set session variables using url variables | OBIEE Blog
    OBIEE 10G - How to set a request/session variable using the Saw Url (Go/Dashboard) | GerardNico.com (BI, OBIEE, O…
    Thanks,
    Satya

  • Service URL not found:session

    Hi,
    I had written a custom authentication module according to the sample given with SunONE doc. But, when I try to login to the portal server, it is throwing the following exception in /opt/SUNWam/debug/amSSOProvider file.
    how to solve this issue:
    I am using SunONE portal server 6.1
    05/13/2004 07:22:54:260 PM GMT+05:30: Thread[Thread-157,5,main]
    could not create SSOToken from HttpRequest
    com.iplanet.dpro.session.SessionException: Service URL not found:session
    at com.iplanet.dpro.session.Session.getSessionServiceURL(Session.java:336)
    at com.iplanet.dpro.session.Session.getSessionServiceURL(Session.java:316)
    at com.iplanet.dpro.session.Session.getSession(Session.java:233)
    at com.iplanet.sso.providers.dpro.SSOProviderImpl.createSSOToken(SSOProviderImpl.java:56)
    at com.iplanet.sso.SSOTokenManager.createSSOToken(SSOTokenManager.java:226)
    at com.sun.portal.desktop.context.DSAMESessionAppContext.getSSOToken(DSAMESessionAppContext.java:67)
    at com.sun.portal.desktop.context.DSAMESessionAppContext.getSessionID(DSAMESessionAppContext.java:99)
    at com.sun.portal.desktop.context.PSDesktopAppContext.getSessionID(PSDesktopAppContext.java:725)
    at com.sun.portal.desktop.context.PSDesktopContextFactory.getDesktopContext(PSDesktopContextFactory.java:91)
    at com.sun.portal.desktop.DesktopServlet.getDesktopContext(DesktopServlet.java:384)
    at com.sun.portal.desktop.DesktopServlet.doGetPost(DesktopServlet.java:413)
    at com.sun.portal.desktop.DesktopServlet.service(DesktopServlet.java:303)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:897)
    at com.iplanet.server.http.servlet.WebApplication.service(WebApplication.java:1065)
    at com.iplanet.server.http.servlet.NSServletRunner.ServiceWebApp(NSServletRunner.java:959)

    seems like you have cookie encode problem,
    based on your
    container you need to set the following property in AMConfig.properties
    in general for welogic and web sphere contianers you need to set it to true
    com.iplanet.am.cookie.encode

  • Cookies, URL-Rewriting, and Sessions

    Hi All,
    I am aware that this is probably a question that has been asked many times in the past. Nonetheless, I have not been able to fully comprehend the differences. Therefore I would appreciate it, if someone could kindly spend some time explaining the differences between the three and when each would be the most preferred solution. ( cookies, url rewriting and sessions )
    So far what I understand is that, cookies can be used to store small amounts of data not more than 4kb, and that most browsers can not accept more than 20 at a time.... but would it be correct to say that the data is stored within the http headers ?
    URL rewriting, on the other hand is a method which can be used if cookies have been disabled by a browser. The 'session id' is appended to the url, and used to remember the data. ( how ? ). Although, it does mean that the programmer has to be very careful and ensure that rewriting occurs everytime it is passed to the browser, including redirection. ( whatever that means ? )
    Http sessions, seem to be the best solution out of the three ( but if this is the case, why are cookies and rewriting still hanging around today ? And even being taught at universities ? ). Also, they work on top of cookies and if these have been disabled sessions will not work !! ....
    As you can see ( from the above ) I do not have a thorough understanding of the three methods, especially if it comes to specifying the differences between the three.
    I would appreciate an explanation.

    HttpSessions use cookies or url rewritting to pass the session id which the server uses to associate a particular session with a particular request. A well developed web application will be written to use url rewriting when a client has cookies disabled. That being said I yet to see such a web application and personally believe that few people still disable cookies.
    Cookies still have uses.
    Persistant cookies are used to store data that needs to persist between sessions. This data is stored by the browser in a text files and passed to the server in the header. An example of this would be a site that offers personalization would store the user's id so that each time the user accesses the site he would see his personalization without being required to log in. Yahoo is a good example.
    In memory cookies are stored in the browser's memory and is used to store temporary data that goes away when the browser closes. Again this data gets passed to the server in the headers. Temporary cookies can be used to pass data between seperate web applications runing on the same host where storing the data in the session will not because each application has it's own session.

  • SSO Exception Invalid Session: Service URL not found:session

    I am running AM 7 (installed from JES) under Sun Web Server 6.1.
    The Policy Agent is installed in Tomcat 5.5 (on the same box).
    I am getting the exception: SSO Exception Invalid Session: Service URL not found:session
    when I try to run the SSO Serlvet example.
    I have searched the forum and found many people get this error and the advice seems to be check the config file. The Agent config file (AMAgent.properties) has all the right parameters in it (matches the server just fine because I authenticate before getting to the serlvet).
    I've tried to set the naming url thru the JVM command line args and programatically. I've been thru the client SDK install chapter many times.
    Still getting the same error.
    Help!
    Jason

    More info: I set the debug level in the AM server to message and in the amSSOProvider log, I get several Invalid Session ID.
    How could this be when I just successfully authenticated???
    I can also go to other protected web pages, and AM does not force me to reauthenticate, so obviously the cookie is good.
    Any help would be appreciated.
    Jason
    03/20/2006 03:05:03:243 PM MST: Thread[main,5,main]
    SSO token ldap auth successful for AuthPrincipal: cn=dsameuser,ou=DSAME Users,dc=ad,dc=gd-ais,dc=com
    03/20/2006 03:05:07:071 PM MST: Thread[main,5,main]
    SSO token ldap auth successful for AuthPrincipal: cn=dsameuser,ou=DSAME Users,dc=ad,dc=gd-ais,dc=com
    03/20/2006 03:05:07:243 PM MST: Thread[main,5,main]
    SSO token ldap auth successful for AuthPrincipal: cn=dsameuser,ou=DSAME Users,dc=ad,dc=gd-ais,dc=com
    03/20/2006 03:05:08:103 PM MST: Thread[main,5,main]
    SSO token ldap auth successful for AuthPrincipal: cn=dsameuser,ou=DSAME Users,dc=ad,dc=gd-ais,dc=com
    03/20/2006 03:05:10:134 PM MST: Thread[main,5,main]
    SSO token ldap auth successful for AuthPrincipal: cn=dsameuser,ou=DSAME Users,dc=ad,dc=gd-ais,dc=com
    03/20/2006 03:05:17:697 PM MST: Thread[main,5,main]
    SSO token ldap auth successful for com.sun.mobile.cdm.MAPClientDetector$1@d61aef
    03/20/2006 03:05:20:400 PM MST: Thread[main,5,main]
    SSO token ldap auth successful for AuthPrincipal: cn=dsameuser,ou=DSAME Users,dc=ad,dc=gd-ais,dc=com
    03/20/2006 03:05:40:713 PM MST: Thread[service-j2ee-1,5,main]
    could not create SSOTOken for token ID
    com.iplanet.dpro.session.SessionException: Invalid session ID.
         at com.iplanet.dpro.session.Session.getSession(Session.java:700)
         at com.iplanet.sso.providers.dpro.SSOProviderImpl.createSSOToken(SSOProviderImpl.java:169)
         at com.iplanet.sso.SSOTokenManager.createSSOToken(SSOTokenManager.java:305)
         at com.sun.identity.authentication.service.AuthUtils.getExistingValidSSOToken(AuthUtils.java:2735)
         at com.sun.identity.authentication.UI.LoginViewBean.forwardTo(LoginViewBean.java:288)
         at com.iplanet.jato.ApplicationServletBase.dispatchRequest(ApplicationServletBase.java:981)
         at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:615)
         at com.iplanet.jato.ApplicationServletBase.doGet(ApplicationServletBase.java:459)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:787)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
         at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
         at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)
    03/20/2006 03:05:40:729 PM MST: Thread[service-j2ee-1,5,main]
    could not create SSOTOken for token ID
    com.iplanet.dpro.session.SessionException: Invalid session ID.
         at com.iplanet.dpro.session.Session.getSession(Session.java:700)
         at com.iplanet.sso.providers.dpro.SSOProviderImpl.createSSOToken(SSOProviderImpl.java:169)
         at com.iplanet.sso.SSOTokenManager.createSSOToken(SSOTokenManager.java:305)
         at com.sun.identity.authentication.service.AuthUtils.getOrigRedirectURL(AuthUtils.java:1443)
         at com.sun.identity.authentication.UI.LoginViewBean.forwardTo(LoginViewBean.java:293)
         at com.iplanet.jato.ApplicationServletBase.dispatchRequest(ApplicationServletBase.java:981)
         at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:615)
         at com.iplanet.jato.ApplicationServletBase.doGet(ApplicationServletBase.java:459)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:787)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
         at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
         at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)
    03/20/2006 03:05:40:729 PM MST: Thread[service-j2ee-1,5,main]
    could not create SSOToken from HttpRequest
    com.iplanet.dpro.session.SessionException: Invalid session ID.
         at com.iplanet.dpro.session.Session.getSession(Session.java:700)
         at com.iplanet.sso.providers.dpro.SSOProviderImpl.createSSOToken(SSOProviderImpl.java:99)
         at com.iplanet.sso.SSOTokenManager.createSSOToken(SSOTokenManager.java:242)
         at com.sun.identity.authentication.service.LoginState.getUserDomain(LoginState.java:1065)
         at com.sun.identity.authentication.service.LoginState.createAuthContext(LoginState.java:1108)
         at com.sun.identity.authentication.service.AuthUtils.getAuthContext(AuthUtils.java:310)
         at com.sun.identity.authentication.service.AuthUtils.getAuthContext(AuthUtils.java:250)
         at com.sun.identity.authentication.UI.LoginViewBean.forwardTo(LoginViewBean.java:325)
         at com.iplanet.jato.ApplicationServletBase.dispatchRequest(ApplicationServletBase.java:981)
         at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:615)
         at com.iplanet.jato.ApplicationServletBase.doGet(ApplicationServletBase.java:459)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:787)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
         at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
         at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)
    03/20/2006 03:05:40:760 PM MST: Thread[service-j2ee-1,5,main]
    could not create SSOToken from HttpRequest
    com.iplanet.dpro.session.SessionException: Invalid session ID.
         at com.iplanet.dpro.session.Session.getSession(Session.java:700)
         at com.iplanet.sso.providers.dpro.SSOProviderImpl.createSSOToken(SSOProviderImpl.java:99)
         at com.iplanet.sso.SSOTokenManager.createSSOToken(SSOTokenManager.java:242)
         at com.sun.identity.authentication.service.AMLoginContext.processIndexType(AMLoginContext.java:1411)
         at com.sun.identity.authentication.service.AMLoginContext.executeLogin(AMLoginContext.java:211)
         at com.sun.identity.authentication.server.AuthContextLocal.login(AuthContextLocal.java:321)
         at com.sun.identity.authentication.server.AuthContextLocal.login(AuthContextLocal.java:257)
         at com.sun.identity.authentication.server.AuthContextLocal.login(AuthContextLocal.java:177)
         at com.sun.identity.authentication.UI.LoginViewBean.getLoginDisplay(LoginViewBean.java:734)
         at com.sun.identity.authentication.UI.LoginViewBean.processLogin(LoginViewBean.java:687)
         at com.sun.identity.authentication.UI.LoginViewBean.forwardTo(LoginViewBean.java:408)
         at com.iplanet.jato.ApplicationServletBase.dispatchRequest(ApplicationServletBase.java:981)
         at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:615)
         at com.iplanet.jato.ApplicationServletBase.doGet(ApplicationServletBase.java:459)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:787)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
         at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
         at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)
    03/20/2006 03:05:45:604 PM MST: Thread[service-j2ee-3,5,main]
    could not create SSOTOken for token ID AQIC5wM2LY4SfcxwMjkeu5nCkvTykKfesYTyhaYeoECCIyQ=@AAJTSQACMDE=#
    com.iplanet.dpro.session.SessionException: Session state is invalid. AQIC5wM2LY4SfcxwMjkeu5nCkvTykKfesYTyhaYeoECCIyQ=@AAJTSQACMDE=#
         at com.iplanet.dpro.session.Session.refresh(Session.java:1046)
         at com.iplanet.dpro.session.Session.getSession(Session.java:725)
         at com.iplanet.sso.providers.dpro.SSOProviderImpl.createSSOToken(SSOProviderImpl.java:169)
         at com.iplanet.sso.SSOTokenManager.createSSOToken(SSOTokenManager.java:305)
         at com.sun.identity.authentication.service.AuthUtils.getExistingValidSSOToken(AuthUtils.java:2735)
         at com.sun.identity.authentication.UI.LoginViewBean.forwardTo(LoginViewBean.java:288)
         at com.iplanet.jato.ApplicationServletBase.dispatchRequest(ApplicationServletBase.java:981)
         at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:615)
         at com.iplanet.jato.ApplicationServletBase.doPost(ApplicationServletBase.java:473)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
         at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
         at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)
    03/20/2006 03:05:45:604 PM MST: Thread[service-j2ee-3,5,main]
    could not create SSOTOken for token ID AQIC5wM2LY4SfcxwMjkeu5nCkvTykKfesYTyhaYeoECCIyQ=@AAJTSQACMDE=#
    com.iplanet.dpro.session.SessionException: Session state is invalid. AQIC5wM2LY4SfcxwMjkeu5nCkvTykKfesYTyhaYeoECCIyQ=@AAJTSQACMDE=#
         at com.iplanet.dpro.session.Session.refresh(Session.java:1046)
         at com.iplanet.dpro.session.Session.getSession(Session.java:725)
         at com.iplanet.sso.providers.dpro.SSOProviderImpl.createSSOToken(SSOProviderImpl.java:169)
         at com.iplanet.sso.SSOTokenManager.createSSOToken(SSOTokenManager.java:305)
         at com.sun.identity.authentication.service.AuthUtils.getOrigRedirectURL(AuthUtils.java:1443)
         at com.sun.identity.authentication.UI.LoginViewBean.forwardTo(LoginViewBean.java:293)
         at com.iplanet.jato.ApplicationServletBase.dispatchRequest(ApplicationServletBase.java:981)
         at com.iplanet.jato.ApplicationServletBase.processRequest(ApplicationServletBase.java:615)
         at com.iplanet.jato.ApplicationServletBase.doPost(ApplicationServletBase.java:473)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
         at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
         at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)

  • URL to set session properties?

    Is there a URL to SET session properties?  I know I can get a list of them by calling "/XMII/PropertyAccessServlet?mode=list&Content-Type=text/xml", but is there a way to set them in a similar manner?

    Hi all,   If you want me to start a new thread let me know...
    I'm having funky, although repeatable, results using the URL to set a session parameter via AJAX call,
    which always gets a Successful message.
    /XMII/PropertyAccessServlet?mode=Store&PropName=plantId&PropValue=60
    I am verifying the session parameter 2 ways:
    1.  Refresh the page and view source  (I took the lt and gt out)
    ...............span id="savedPlantId" style="visibility:hidden;"
    2.  AJAX call to /XMII/PropertyAccessServlet?mode=List
    Quirk #1:   I see the value in the span.  I do not see it in the servlet list.
    Quirk #2:   I can change the value a couple (2 or 3 times) then it doesn't change after that
    Quirk #3:   When it stops changing via the AJAX call, I can still change it with a browser URL
    http://<server>:50000/XMII/PropertyAccessServlet?mode=Store&PropName=plantId&PropValue=199
    Any hints or ideas? 
    Yes, I am trying to use a single pixel applet, but having trouble with that too!  See a different post. 
    I really would prefer to use the URL as there is no visual indication to the user
    and an applet (and JVM) doesn't have to load.
    --Amy Smith
    --Haworth
    Oh, and P.S.   Is there a mode=Delete to remove the session parameter?

  • Checking URLs via HttpURLConnection

    Below is the code for a very simple Java application which tries to connect to 3 URL's to check whether the links are broken. The links are:
    http://www.sckk.dk
    http://www.sckk.dk/visSCKKForside.asp?artikelID=1261
    http://www.sckk.dk/visSCKKArtikel.asp?artikelID=2214
    They can be easily accessed using a browser, yet when using the HttpURLConnection, a Internal Server Error (500) is returned. setFollowRedirects(true) does not change this behaviour. I've been looking for an explanation all over the web and haven't found any, so any insight is most appreciated.
    import java.net.HttpURLConnection;
    import java.net.URL;
    public class SimpleConnector {
        public static void checkUrl(String urlString){
            try{
                  URL url = new URL(urlString);
                  HttpURLConnection.setFollowRedirects(false);
                  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                  //connection.setRequestMethod("HEAD");
                  connection.connect();
                  System.out.println("Redirect location:    " + connection.getHeaderField("Location"));
                  System.out.println("URL:                  " + connection.getURL());
                  System.out.println("Response code =       " + connection.getResponseCode());
                  System.out.println("Response message =    " + connection.getResponseMessage() + "\n");
                  connection.disconnect();
                } catch(Exception e){
                    System.out.println(e.getMessage());
        public static void main(String[] args) {
            SimpleConnector sc = new SimpleConnector();
            sc.checkUrl("http://www.sckk.dk");
            sc.checkUrl("http://www.sckk.dk/visSCKKForside.asp?artikelID=1261");
            sc.checkUrl("http://www.sckk.dk/visSCKKArtikel.asp?artikelID=2214");
    }

    (I'm the OP, for some reason I can't recover my password for my initial account at the moment)
    Just wanted to tell you (DrClap) that I managed to solve the "riddle", inspired by your reply! I added the following line to the code, "masking" my application as a browser (IE 6.0 on a Win XP machine if I'm not mistaken):
    connection.setRequestProperty("user agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1")The troublesome websites now respond correctly.
    I'm relatively new to http-related work, so mentioning the user agent header lead me in the right direction. Thanks!
    P.S. I'll try to award you the duke stars once I'm able to retrieve my password.

  • Handling complex URLs with HttpURLConnection

    The problem I am facing is that when I try opening a complex URL using HTTPUrlConnection, I get a Bad Request Error.
    For eg: f the URL is simple (as shown below) the code works fine.
    URL urlPage = new URL( "http://www.google.com" );
    HttpURLConnection hucnCon = ( HttpURLConnection ) urlPage.openConnection();
    But if the URL conatins some special charcters like
    "http://www.google.com/search?q=HTTPURLConnection+Example&hl=en&start=30&sa=N"
    I get a bad request page.
    I had be grateful if somebody could provide me with a solution to this.
    Thanks

    Hi ,
    Thanks for the posting but if I dfo this
    URL urlPage = new URL( URLEncoder.encode("http://www.google.com/search?hl=en&q=dcm&btnG=Google+Search") );
    I end up getting a malformedURLException.
    Thanks

  • Problems with URLConnection and sessions

    Hi all,
    I'm having a problem with some applet - php communication. We have a website that you log in to. The website is in php, and I have no idea what it does, because another guy is handling it. My applet takes in information about the session id and stuff like that, and whenever I want to communicate with a page, I send the id and the requests using a post method. I've got a simple post method which writes a string to a url, then opens an input stream from that connection. Here's the code:
            /**This method posts the given string to the given URL and returns the InputStream from the URL*/
         public InputStream postToURL(URL postURL, String post) throws IOException{
              URLConnection connect = postURL.openConnection();
              connect.setDoOutput(true);
              connect.setUseCaches(false);
              OutputStreamWriter fwdOut = new OutputStreamWriter(connect.getOutputStream());
              fwdOut.write(post);
              fwdOut.flush();
              fwdOut.close();
              return connect.getInputStream();
         }I just noticed that when you run this, it logs you out of your session on the website. I commented out parts and found out that it actually doesn't log you out until I call connect.getInputStream(). I have no idea if this is the applet's fault, or the php's fault. I was hoping that some of you might have some insight as to what the problem is, and if there is something on the applet side I should change to make it work. If it is the php side, then sorry for wasting your time, and hopefully the other guy will catch it.

    shiroganeookami wrote:
    I just wanted to clarify, the session information I'm getting is actually just a login id that is used to confirm if someone has access to certain files, so it actually isn't the session information, like I thought.If I understand you correctly.
    Your are logged in to the site in PHP.
    On the site is an applet.
    When the applet connects back to the site (and you are not using the session or login here) the BROWSER loses it's session.
    Is this correct?
    If so the problem is some shoddy PHP coding. A session or whatever it is that they are actually doing is maintained using HTTP cookies. The browser's cookies are not being wiped by the Applet. What I suspect is happening is that the PHP is doing something with IP addresses and is wiping the browser session when the applet connects from the same address. Which is a mistake for a bunch of reasons.
    If it's something else then please explain what.

  • Differences of URLConnection,HttpURLConnection,HttpsURLConnection

    I find that all of them can connect to HTTPS,but what are differences of them when them are used to connected to HTTPS
    Any help is appreciated.
    Thanks in advance.

    Thanks a lot.
    But
    If URL="https://www.sun.com",
    URLConnection con;
    HttpURLConnection httpcon;
    HttpsURLConnection httpscon;
    con=URL.openConnection
    httpcon=(HttpURLConnection)URL.openConnection
    httpscon=(HttpsURLConnection)URL.openConnection
    what are the differences of con,httpcon,httpscon?
    All of them can get infomation from the URL based HTTPS protocol.

  • Setting Timeout  in URLConnection/HttpURLConnection

    Hi all,
    I am trying to open a connection a website using the java.net.HttpURLConnection.
    Please tell me what is the default timeout (how much time it will wait for getting reply ) and how we can change the
    default value. Please help me.
    Thanks in advance.

    This seems to be what you are looking for.
    [http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLConnection.html#setReadTimeout%28int%29|http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLConnection.html#setReadTimeout%28int%29]

Maybe you are looking for