?
Solved

the resutl of an Exception

Posted on 2003-03-03
5
Medium Priority
?
170 Views
Last Modified: 2013-11-24
I am using Tomcat, and I created a form, and servlet to handle the data parsing. But, I want the output of the servlet in a pop-up window. ( a small popup with "ok done" or "not ok, this is wrong" blabla...)

in other words, how can I throw an exception in a popup-window ?
0
Comment
Question by:ap458889
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 1

Accepted Solution

by:
umangjoshi earned 70 total points
ID: 8056745
try
{
}
catch(Exception e)
{
    pw.write("<script language=JavaScript>");
    pw.write(" popWin = window.open('ServletURL','aaa','scrollbars=yes,width=100,height=100,top=100,left=100,menubar=no');
    pw.write("</script>");
}

---------------
ServletURL: you have to create other servlet and pass necessarry information requires to display proper message.
0
 

Author Comment

by:ap458889
ID: 8056870
what is pw ? pw.write(...)
Thanks !
0
 

Author Comment

by:ap458889
ID: 8056887
what is pw ? pw.write(...)
Thanks !
0
 

Author Comment

by:ap458889
ID: 8057042
Sorry for the previous question...
I did it like this:

PrintWriter pw = response.getWriter();
pw.println("<script language=JavaScript>");
pw.println(" popWin = window.open('/user/error.jsp','aaa','scrollbars=yes,width=100,height=100,top=100,left=100,menubar=no')");
pw.println("</script>");

but: this will create a popup, BUT the form is submitted, so the actual window is black... the same window should be there.

Thx
0
 
LVL 2

Expert Comment

by:cocojohn
ID: 8057187
You can post the form into the popup window:

<script language="javascript">
  function doSubmit(){
    win2 = window.open("", win2, "height:200,width:200");
    document.myForm.target = "win2";
    document.myForm.submit();
  }
</script>

<form action="theServlet" name="myForm" onSubmit="doSubmit();">
  <!-- form elements -->
</form>

When myForm is submitted, the JavaScript opens a popup windows and changes the form's target.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question