Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By gimbal2

Thread: Java URLConnection not authenticating?

  1. #1
    PLFC is offline Member
    Join Date
    Oct 2015
    Rep Power

    Default Java URLConnection not authenticating?

    Hi everyone,

    I'm not sure if this is the correct section to post this question but I believe it is. I'm trying to develop a simple java code that will connect to Oracle Business Intelligence Enterprise Edition 11g (OBIEE). What I'm trying to achieve is running some code that will open a dashboard page in OBIEE and then monitor (directly in OBIEE) which queries are triggered.

    The code I have right now is pretty basic and is the following:

    Java Code:
    public class ConnectionTest {
        public static void main(String[] args) {
            try {
                URL myURL =
                    new URL("http://server:port/analytics/saw.dll?Dashboard&PortalPath=%2Fshared%2FHE%20Analytics%2F_portal%2FHE%20Analytics&NQUser=weblogic&NQPassword=welcome1");
                URLConnection myURLConnection = myURL.openConnection();
                                                   "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)");
                BufferedReader in =
                    new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
                String inputLine;
                while ((inputLine = in.readLine()) != null)
            } catch (MalformedURLException e) {
                System.out.println("Exception " + e);
            } catch (IOException e) {
                System.out.println("Exception " + e);
    What is strange about the behaviour of this code is that I'm able to see the user, apparently, logged in into OBIEE (the user is listed on the active sessions) but no queries are triggered and what is returned in the BufferedReader actually shows that it's still trying to login (below just some pieces of the HTML returned which shows the login page)

    <title>Signing in...</title>

    <script type="text/javascript">window.onload=function(){onLoggingInPa geLoad('saw.dll?Dashboard',{"page":"Student Withdrawal Profile","PortalPath":"/shared/HE Analytics/_portal/HE Analytics"});};</script>

    I've also tried add to my Java code the lines below but it didn't make any difference.

    Java Code:
    String userpass = "weblogic" + ":" + "welcome1";
    String basicAuth = "Basic " + new String(new Base64().encode(userpass.getBytes()));
    myURLConnection.setRequestProperty ("Authorization", basicAuth);
    In my last try I tried to use an HTTPURLConnection, setting the request method but once again, no luck.

    Java Code:
    HttpURLConnection myURLConnection= (HttpURLConnection)myURL.openConnection();
    I'm aware that this may not be only a Java problem but also something related to OBIEE itself but I'm kind of stuck right now and decided to post here in case I'm missing something very obvious that I'm not aware of! Any help will be much appreciated!

    Last edited by PLFC; 10-12-2015 at 03:20 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Java URLConnection not authenticating?

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Java URLConnection not authenticating?

    That page is executing some Javascript onLoad.
    That Javascript will not be run, so presumably will not result in any of the queries you expect.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    PLFC is offline Member
    Join Date
    Oct 2015
    Rep Power

    Default Re: Java URLConnection not authenticating?

    Hi Tolls,

    Thanks for the reply. However, if I pick that URL I use in my URL object and put it directly into a browser, I'm able to see the expected dashboard. The same will happen if I open that URL in a simple HTML page. Wouldn't that suggest that is there something in the Java code missing that prevents the expected behaviour (opening the dashboard page)?

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Rep Power

    Default Re: Java URLConnection not authenticating?

    Yes - a browser invoking the javascript in the page. That's what you are missing in the Java code. The only part of the request you're doing is to fire a HTTP request and fetch the page content as plain text, any of the massively complicated things that the browser does after that which includes but is not limited to:

    - rendering the page
    - applying CSS
    - fetch remaining resources such as images and rendering those too
    - invoking any and all javascript in the page and computing and applying the outcome of said javascript

    your application is not doing. If you'd think that this stuff was so easy you can do it with a few lines of Java code, then download the source of Firefox and wonder why it is literally millions of lines of code.
    Last edited by gimbal2; 10-13-2015 at 01:28 PM. Reason: fix readability
    PLFC likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. URLConnection Question
    By rru96 in forum New To Java
    Replies: 0
    Last Post: 10-21-2013, 07:50 AM
  2. URLConnection
    By warrier in forum Networking
    Replies: 4
    Last Post: 02-18-2013, 05:22 PM
  3. URLConnection
    By tnrh1 in forum New To Java
    Replies: 9
    Last Post: 12-20-2011, 02:03 PM
  4. IntelliJ failed in authenticating Subversion repository
    By wasi_shez in forum IntelliJ IDEA
    Replies: 2
    Last Post: 04-26-2011, 02:20 PM
  5. Authenticating for a java POST request
    By stodds in forum Advanced Java
    Replies: 1
    Last Post: 12-08-2010, 12:11 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts