Example usage for java.net URL sameFile

List of usage examples for java.net URL sameFile

Introduction

In this page you can find the example usage for java.net URL sameFile.

Prototype

public boolean sameFile(URL other) 

Source Link

Document

Compares two URLs, excluding the fragment component.

Returns true if this URL and the other argument are equal without taking the fragment component into consideration.

Usage

From source file:com.gargoylesoftware.htmlunit.html.BaseFrameElement.java

/**
 * Test if the provided URL is the one of one of the parents which would cause an infinite loop.
 * @param url the URL to test/*  w w  w.  j  a  v  a2s .c o m*/
 * @return {@code false} if no parent has already this URL
 */
private boolean isAlreadyLoadedByAncestor(final URL url) {
    WebWindow window = getPage().getEnclosingWindow();
    while (window != null) {
        if (url.sameFile(window.getEnclosedPage().getUrl())) {
            return true;
        }
        if (window == window.getParentWindow()) {
            // TODO: should getParentWindow() return null on top windows?
            window = null;
        } else {
            window = window.getParentWindow();
        }
    }
    return false;
}

From source file:guineu.desktop.impl.helpsystem.GuineuHelpMap.java

/**
 * Determines the IDs related to this URL.
 *
 * @param URL//  ww w . j a v a 2  s  . c  o m
 *            The URL to compare the Map IDs to.
 * @return Enumeration of Map.IDs
 */
@Override
public Enumeration<Object> getIDs(URL url) {
    String tmp = null;
    URL tmpURL = null;
    List<String> ids = new ArrayList<String>();
    for (Enumeration<String> e = getAllIDs(); e.hasMoreElements();) {
        String key = (String) e.nextElement();
        try {
            tmp = (String) lookup.get(key);
            tmpURL = new URL(tmp);
            if (url.sameFile(tmpURL) == true) {
                ids.add(key);
            }
        } catch (Exception ex) {
        }
    }
    return new FlatEnumeration(ids.listIterator(), helpset);
}

From source file:EditorPaneExample12.java

public void loadNewPage(Object page) {
    try {//from  w  w w .  j  a  va 2  s.c  om
        loadingPage = true;

        // Check if the new page and the old
        // page are the same.
        URL url;
        if (page instanceof URL) {
            url = (URL) page;
        } else {
            url = new URL((String) page);
        }

        urlCombo.setSelectedItem(page);

        URL loadedURL = pane.getPage();
        if (loadedURL != null && loadedURL.sameFile(url)) {
            return;
        }

        // Try to display the page
        urlCombo.setEnabled(false); // Disable input
        urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
        setCursor(waitCursor); // Busy cursor
        loadingState.setText("Loading...");
        loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height);
        loadedType.setText("");
        loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

        timeLabel.setText("");
        timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

        // Display an empty tree while loading
        tree.setModel(emptyModel);
        tree.paintImmediately(0, 0, tree.getSize().width, tree.getSize().height);

        startTime = System.currentTimeMillis();

        // Choose the loading method
        if (onlineLoad.isSelected()) {
            // Usual load via setPage
            pane.setPage(url);
            loadedType.setText(pane.getContentType());
        } else {
            pane.setContentType("text/html");
            loadedType.setText(pane.getContentType());
            if (loader == null) {
                loader = new HTMLDocumentLoader();
            }
            HTMLDocument doc = loader.loadDocument(url);
            loadComplete();
            pane.setDocument(doc);
            displayLoadTime();
            populateCombo(findLinks(doc, null));
            TreeNode node = buildHeadingTree(doc);
            tree.setModel(new DefaultTreeModel(node));
            enableInput();
            loadingPage = false;
        }
    } catch (Exception e) {
        System.out.println(e);
        JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", page.toString() },
                "File Open Error", JOptionPane.ERROR_MESSAGE);
        loadingState.setText("Failed");
        enableInput();
        loadingPage = false;
    }
}

From source file:EditorPaneExample15.java

public void loadNewPage(Object page) {
    try {/*from   w  w  w . j a  v  a 2 s .c o m*/
        loadingPage = true;

        // Check if the new page and the old
        // page are the same.
        URL url;
        if (page instanceof URL) {
            url = (URL) page;
        } else {
            url = new URL((String) page);
        }

        urlCombo.setSelectedItem(page);

        URL loadedURL = pane.getPage();
        if (loadedURL != null && loadedURL.sameFile(url)) {
            return;
        }

        // Try to display the page
        urlCombo.setEnabled(false); // Disable input
        urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
        setCursor(waitCursor); // Busy cursor
        loadingState.setText("Loading...");
        loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height);
        loadedType.setText("");
        loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

        timeLabel.setText("");
        timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

        // Display an empty tree while loading
        tree.setModel(emptyModel);
        tree.paintImmediately(0, 0, tree.getSize().width, tree.getSize().height);

        startTime = System.currentTimeMillis();

        // Choose the loading method
        if (onlineLoad.isSelected()) {
            // Usual load via setPage
            pane.setPage(url);
            loadedType.setText(pane.getContentType());
        } else {
            pane.setContentType("text/html");
            loadedType.setText(pane.getContentType());
            if (loader == null) {
                loader = new HTMLDocumentLoader();
            }
            HTMLDocument doc = loader.loadDocument(url);

            // Modify styles for this document only
            modifyStyleSheet(doc.getStyleSheet());

            loadComplete();
            pane.setDocument(doc);
            displayLoadTime();
            populateCombo(findLinks(doc, null));
            TreeNode node = buildHeadingTree(doc);
            tree.setModel(new DefaultTreeModel(node));
            enableInput();
            loadingPage = false;
        }
    } catch (Exception e) {
        System.out.println(e);
        JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", page.toString() },
                "File Open Error", JOptionPane.ERROR_MESSAGE);
        loadingState.setText("Failed");
        enableInput();
        loadingPage = false;
    }
}

From source file:EditorPaneExample16.java

public void loadNewPage(Object page) {
    try {//  www. j  a va  2s  .c om
        loadingPage = true;

        // Check if the new page and the old
        // page are the same.
        URL url;
        if (page instanceof URL) {
            url = (URL) page;
        } else {
            url = new URL((String) page);
        }

        urlCombo.setSelectedItem(page);

        URL loadedURL = pane.getPage();
        if (loadedURL != null && loadedURL.sameFile(url)) {
            return;
        }

        // Try to display the page
        urlCombo.setEnabled(false); // Disable input
        urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
        setCursor(waitCursor); // Busy cursor
        loadingState.setText("Loading...");
        loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height);
        loadedType.setText("");
        loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

        timeLabel.setText("");
        timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

        // Display an empty tree while loading
        tree.setModel(emptyModel);
        tree.paintImmediately(0, 0, tree.getSize().width, tree.getSize().height);

        startTime = System.currentTimeMillis();

        // Choose the loading method
        if (onlineLoad.isSelected()) {
            // Usual load via setPage
            pane.setPage(url);
            loadedType.setText(pane.getContentType());
        } else {
            pane.setContentType("text/html");
            loadedType.setText(pane.getContentType());
            if (loader == null) {
                loader = new HTMLDocumentLoader();
            }
            HTMLDocument doc = loader.loadDocument(url);

            loadComplete();
            pane.setDocument(doc);
            displayLoadTime();
            populateCombo(findLinks(doc, null));
            TreeNode node = buildHeadingTree(doc);
            tree.setModel(new DefaultTreeModel(node));
            enableInput();
            loadingPage = false;
        }
    } catch (Exception e) {
        System.out.println(e);
        JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", page.toString() },
                "File Open Error", JOptionPane.ERROR_MESSAGE);
        loadingState.setText("Failed");
        enableInput();
        loadingPage = false;
    }
}

From source file:EditorPaneExample11.java

public EditorPaneExample11() {
    super("JEditorPane Example 11");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;/*from   w w  w . jav  a 2 s  .  co  m*/
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            try {
                // Check if the new page and the old
                // page are the same.
                URL url;
                if (selection instanceof URL) {
                    url = (URL) selection;
                } else {
                    url = new URL((String) selection);
                }

                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(url)) {
                    return;
                }

                // Try to display the page
                urlCombo.setEnabled(false); // Disable input
                urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

                timeLabel.setText("");
                timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

                // Display an empty tree while loading
                tree.setModel(emptyModel);
                tree.paintImmediately(0, 0, tree.getSize().width, tree.getSize().height);

                startTime = System.currentTimeMillis();

                // Choose the loading method
                if (onlineLoad.isSelected()) {
                    // Usual load via setPage
                    pane.setPage(url);
                    loadedType.setText(pane.getContentType());
                } else {
                    pane.setContentType("text/html");
                    loadedType.setText(pane.getContentType());
                    if (loader == null) {
                        loader = new HTMLDocumentLoader();
                    }
                    HTMLDocument doc = loader.loadDocument(url);
                    loadComplete();
                    pane.setDocument(doc);
                    displayLoadTime();
                    populateCombo(findLinks(doc, null));
                    TreeNode node = buildHeadingTree(doc);
                    tree.setModel(new DefaultTreeModel(node));
                    enableInput();
                }
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane,
                        new String[] { "Unable to open file", selection.toString() }, "File Open Error",
                        JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                enableInput();
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));
                enableInput();
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });
}

From source file:EditorPaneExample19.java

public void loadNewPage(Object page) {
    try {/*from   w  ww .  j a va2  s.  c  o m*/
        loadingPage = true;

        // Check if the new page and the old
        // page are the same.
        URL url;
        if (page instanceof URL) {
            url = (URL) page;
        } else {
            url = new URL((String) page);
        }

        urlCombo.setSelectedItem(page);

        URL loadedURL = pane.getPage();
        if (loadedURL != null && loadedURL.sameFile(url)) {
            return;
        }

        enableMenuBar(false);
        urlCombo.paintImmediately(0, 0, menuBar.getSize().width, menuBar.getSize().height);

        // Try to display the page
        urlCombo.setEnabled(false); // Disable input
        urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
        setCursor(waitCursor); // Busy cursor
        loadingState.setText("Loading...");
        loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height);
        loadedType.setText("");
        loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

        timeLabel.setText("");
        timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

        // Display an empty tree while loading
        tree.setModel(emptyModel);
        tree.paintImmediately(0, 0, tree.getSize().width, tree.getSize().height);

        startTime = System.currentTimeMillis();

        // Choose the loading method               
        if (onlineLoad.isSelected()) {
            // Usual load via setPage
            pane.setPage(url);
            loadedType.setText(pane.getContentType());
        } else {
            pane.setContentType("text/html");
            loadedType.setText(pane.getContentType());
            if (loader == null) {
                loader = new HTMLDocumentLoader();
            }
            HTMLDocument doc = loader.loadDocument(url);

            loadComplete();
            pane.setDocument(doc);
            displayLoadTime();
            populateCombo(findLinks(doc, null));
            TreeNode node = buildHeadingTree(doc);
            tree.setModel(new DefaultTreeModel(node));

            createMenuBar();
            enableMenuBar(true);
            getRootPane().revalidate();

            enableInput();
            loadingPage = false;
        }
    } catch (Exception e) {
        System.out.println(e);
        JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", page.toString() },
                "File Open Error", JOptionPane.ERROR_MESSAGE);
        loadingState.setText("Failed");
        enableMenuBar(true);
        enableInput();
        loadingPage = false;
    }
}

From source file:EditorPaneExample20.java

public void loadNewPage(Object page) {
    try {/*from w  w  w .  jav a2s .com*/
        loadingPage = true;

        // Check if the new page and the old
        // page are the same.
        URL url;
        if (page instanceof URL) {
            url = (URL) page;
        } else {
            url = new URL((String) page);
        }

        urlCombo.setSelectedItem(page);

        URL loadedURL = pane.getPage();
        if (loadedURL != null && loadedURL.sameFile(url)) {
            return;
        }

        enableMenuBar(false);
        urlCombo.paintImmediately(0, 0, menuBar.getSize().width, menuBar.getSize().height);

        // Try to display the page
        urlCombo.setEnabled(false); // Disable input
        urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
        setCursor(waitCursor); // Busy cursor
        loadingState.setText("Loading...");
        loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height);
        loadedType.setText("");
        loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

        timeLabel.setText("");
        timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

        // Display an empty tree while loading
        tree.setModel(emptyModel);
        tree.paintImmediately(0, 0, tree.getSize().width, tree.getSize().height);

        startTime = System.currentTimeMillis();

        // Choose the loading method
        if (onlineLoad.isSelected()) {
            // Usual load via setPage
            pane.setPage(url);
            loadedType.setText(pane.getContentType());
        } else {
            pane.setContentType("text/html");
            loadedType.setText(pane.getContentType());
            if (loader == null) {
                loader = new HTMLDocumentLoader();
            }
            HTMLDocument doc = loader.loadDocument(url);

            loadComplete();
            pane.setDocument(doc);
            displayLoadTime();
            populateCombo(findLinks(doc, null));
            TreeNode node = buildHeadingTree(doc);
            tree.setModel(new DefaultTreeModel(node));

            createMenuBar();
            enableMenuBar(true);
            getRootPane().revalidate();

            enableInput();
            loadingPage = false;
        }
    } catch (Exception e) {
        System.out.println(e);
        JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", page.toString() },
                "File Open Error", JOptionPane.ERROR_MESSAGE);
        loadingState.setText("Failed");
        enableMenuBar(true);
        enableInput();
        loadingPage = false;
    }
}

From source file:com.gargoylesoftware.htmlunit.WebClient.java

/**
 * Send a request to a server and return a Page that represents the
 * response from the server. This page will be used to populate the provided window.
 * <p>/*from   ww  w  . j  av a 2s .  c o m*/
 * The returned {@link Page} will be created by the {@link PageCreator}
 * configured by {@link #setPageCreator(PageCreator)}, if any.
 * <p>
 * The {@link DefaultPageCreator} will create a {@link Page} depending on the content type of the HTTP response,
 * basically {@link HtmlPage} for HTML content, {@link com.gargoylesoftware.htmlunit.xml.XmlPage} for XML content,
 * {@link TextPage} for other text content and {@link UnexpectedPage} for anything else.
 *
 * @param webWindow the WebWindow to load the result of the request into
 * @param webRequest the web request
 * @param <P> the page type
 * @return the page returned by the server when the specified request was made in the specified window
 * @throws IOException if an IO error occurs
 * @throws FailingHttpStatusCodeException if the server returns a failing status code AND the property
 *         {@link WebClientOptions#setThrowExceptionOnFailingStatusCode(boolean)} is set to true
 *
 * @see WebRequest
 */
@SuppressWarnings("unchecked")
public <P extends Page> P getPage(final WebWindow webWindow, final WebRequest webRequest)
        throws IOException, FailingHttpStatusCodeException {

    final Page page = webWindow.getEnclosedPage();

    if (page != null) {
        final URL prev = page.getUrl();
        final URL current = webRequest.getUrl();
        if (page.getWebResponse().getWebRequest().isCloneForHistoryAPI() || (current.sameFile(prev)
                && current.getRef() != null && !StringUtils.equals(current.getRef(), prev.getRef()))) {
            // We're just navigating to an anchor within the current page.
            page.getWebResponse().getWebRequest().setUrl(current);
            webWindow.getHistory().addPage(page);
            final Window window = (Window) webWindow.getScriptableObject();
            if (window != null) { // js enabled
                window.getLocation().setHash(current.getRef());
            }
            return (P) page;
        }

        if (page.isHtmlPage()) {
            final HtmlPage htmlPage = (HtmlPage) page;
            if (!htmlPage.isOnbeforeunloadAccepted()) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("The registered OnbeforeunloadHandler rejected to load a new page.");
                }
                return (P) page;
            }
        }
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("Get page for window named '" + webWindow.getName() + "', using " + webRequest);
    }

    final WebResponse webResponse;
    final String protocol = webRequest.getUrl().getProtocol();
    if ("javascript".equals(protocol)) {
        webResponse = makeWebResponseForJavaScriptUrl(webWindow, webRequest.getUrl(), webRequest.getCharset());
        if (webWindow.getEnclosedPage() != null
                && webWindow.getEnclosedPage().getWebResponse() == webResponse) {
            // a javascript:... url with result of type undefined didn't changed the page
            return (P) webWindow.getEnclosedPage();
        }
    } else {
        webResponse = loadWebResponse(webRequest);
    }

    printContentIfNecessary(webResponse);
    loadWebResponseInto(webResponse, webWindow);

    // start execution here
    // note: we have to do this also if the server reports an error!
    //       e.g. if the server returns a 404 error page that includes javascript
    if (scriptEngine_ != null) {
        scriptEngine_.registerWindowAndMaybeStartEventLoop(webWindow);
    }

    // check and report problems if needed
    throwFailingHttpStatusCodeExceptionIfNecessary(webResponse);
    return (P) webWindow.getEnclosedPage();
}

From source file:com.gargoylesoftware.htmlunit.WebClient.java

/**
 * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
 *
 * Perform the downloads and stores it for loading later into a window.
 * In the future downloads should be performed in parallel in separated threads.
 * TODO: refactor it before next release.
 * @param requestingWindow the window from which the request comes
 * @param target the name of the target window
 * @param request the request to perform
 * @param checkHash if true check for hashChenage
 * @param forceLoad if true always load the request even if there is already the same in the queue
 * @param description information about the origin of the request. Useful for debugging.
 *//*from   ww w.j  ava2s  .  c o  m*/
public void download(final WebWindow requestingWindow, final String target, final WebRequest request,
        final boolean checkHash, final boolean forceLoad, final String description) {
    final WebWindow win = resolveWindow(requestingWindow, target);
    final URL url = request.getUrl();
    boolean justHashJump = false;

    if (!request.isCloneForHistoryAPI()) {
        if (win != null && HttpMethod.POST != request.getHttpMethod()) {
            final Page page = win.getEnclosedPage();
            if (page != null) {
                if (page.isHtmlPage() && !((HtmlPage) page).isOnbeforeunloadAccepted()) {
                    return;
                }

                if (checkHash) {
                    final URL current = page.getUrl();
                    justHashJump = HttpMethod.GET == request.getHttpMethod() && url.sameFile(current)
                            && null != url.getRef();
                }
            }
        }

        synchronized (loadQueue_) {
            // verify if this load job doesn't already exist
            for (final LoadJob loadJob : loadQueue_) {
                if (loadJob.response_ == null) {
                    continue;
                }
                final WebRequest otherRequest = loadJob.request_;
                final URL otherUrl = otherRequest.getUrl();

                // TODO: investigate but it seems that IE considers query string too but not FF
                if (!forceLoad && url.getPath().equals(otherUrl.getPath()) // fail fast
                        && url.toString().equals(otherUrl.toString())
                        && request.getRequestParameters().equals(otherRequest.getRequestParameters())
                        && StringUtils.equals(request.getRequestBody(), otherRequest.getRequestBody())) {
                    return; // skip it;
                }
            }
        }
    }

    final LoadJob loadJob;
    if (justHashJump || request.isCloneForHistoryAPI()) {
        loadJob = new LoadJob(request, requestingWindow, target, url);
    } else {
        try {
            final WebResponse response = loadWebResponse(request);
            loadJob = new LoadJob(request, requestingWindow, target, response);
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
    }
    synchronized (loadQueue_) {
        loadQueue_.add(loadJob);
    }
}