开发者

javascript dialogbox without opening page

I have to display dialog box from servlet but without opening new window.

Below is code

PrintWriter printWriter =response.getWriter();
 String s ="<HTML><HEAD><TITLE>JavaScript Example</TITLE>"+
"<SCRIPT LANGUAGE=JavaScript>"+
 "alert('File Uploaded');"+
 "</SCRIPT>"+
   "</HEAD>"+
  "</HTML>";

printWriter.print(s);

This code open dialog in new window开发者_开发问答 but I want dialog in current window.


It's hard to understand your problem. The posted code isn't opening a new window at all, it's just displaying an alert dialog. If you mean to say that it is opening a new window and then displaying the alert, then the problem rather lies in the calling code. Maybe you have a target="_blank" in the link or the form which is calling the servlet?


That said, generating view code in a servlet isn't always the best practice. JSP should be used for that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜