If you want to display a javascript alert or confirm box without changing the current page displayed, then I would use a hidden frame at the bottom of your page. Set the javascript src property on this frame to the url of your servlet/JSP that generates the message.
<html>
<body>
<img src="image/mygif.gif"
onclick="document.getElementById('alertFrame').src = 'myPopJsp.jsp'">
<iframe id="alertFrame" frameborder=0 height=0 width=0
src="javascript:''"></iframe>
</body>
</html>
Mozilla and crowd do not respond to setting the src property unless the frame originally has a meaningful SRC attribute. Hence the SRC attribute to generate a blank page via javascript.
The JSP to generate an alert might look like this:
<html>
<head>
<script type="text/javascript"><!--
function init(){
alert('<%= myMessage %>');
window.location.replace('javascript:""');
}
//--></script>
</head>
<body onload="init();">
</body>
</html>
The window.location.replace() again sets the frame to contain a blank javascript generated page. If you don't do this, then if the user refreshes the page, the alert will appear for a second time. On some browsers it will also remove the hidden page from the history list, so when the user presses the back button for the first time, it doesn't appear to do nothing.
However, if you don't want a javascript alert(), but want another window to open, I suggest you look at
http://developer.netscape.com/viewsource/goodman_modal/goodman_modal.html