Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to open window in a new tab via JSP?

Hi,

We have an external third party report that integrated with Confluence 7.0.3. We created a JSP file and set the JSP file as a space shortcut for a specific space. When user click the shortcut, system will pass the current login account with post method through the JSP file and then open a window in new tab. The login account is used to read allowed Confluence pages in the external report and the post method is used for security concern. This way works fine before upgrade Confluence.

After we upgraded to Confluence 7.4.9, it does not work anymore. The JSP does not open new window due to window.open() returns null. And I also find a message "Use of `window._` through AUI is deprecated and will be removed in AUI 9.0" in browser console.

Here is my question: Is there any solution to pass the current login account to external third party page with post method? Please help. Thank you!

Below is the JSP for your reference.

<%@page import="com.atlassian.crowd.embedded.api.User" %>
<%@page import="java.security.Principal" %>

<%

// prevent browser cache jsp
response.setHeader("Pragma", "No-cache"); // HTTP 1.0
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setDateHeader("Expires", -1); // proxies

String _user = "";

try {
_user = ((Principal)session.getAttribute("seraph_defaultauthenticator_user")).getName();
} catch(Exception e) {
}
%>


<html>

<head>

<title>Comparison Report</title>

<script>
function openWindowWithPost(url, name, keys, values)
{
var newWindow = window.open(url, name);

if (!newWindow) return false;

var html = "";
html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>";
if (keys && values) html += "<input type='hidden' name='" + keys + "' value='" + values + "'/>";
html += "</form><script type='text/javascript'>document.getElementById('formid').submit();";
html += "<\/script></body></html>".toString().replace(/^.+?\*|\\(?=\/)|\*.+?$/gi, "");

newWindow.document.write(html);
return newWindow;

}

openWindowWithPost("https://xxx.xxx.xxx/CmpReport.aspx", "_blank", ["username"], ["<%= _user %>"]);

window.location = window.document.referrer;
</script>
</head>

</html>

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

🏑 Atlympic Event: Confluence

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

161 views 5 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you