aspose file tools*
The moose likes Servlets and the fly likes Opening Pop up WIndow from action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Opening Pop up WIndow from action class" Watch "Opening Pop up WIndow from action class" New topic
Author

Opening Pop up WIndow from action class

vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
Hi,
I want to know if there is anyway I can open a pop up window (a jsp) using action class.

The flow will like this. I have the message to appear in the jsp pop up page in the action class. I need to print the message in the pop up window. Is it possible from action class, or should I pass the string to my servlet. Is it possible to open pop up window from servlet? Please let me know if this is possible or not.


Actually my requirement is as follows.

I have a login.jsp. After I enter the details I get an arraylist from the servlet and display in the customer.jsp. The customer has options to enter more details. After he enters he has an option to save it. He can use a button to save the new entered details.
The customer also has an option to generate the old and new details in String form, i.e it will be having all the new values and old values arranged in order. Hence this is dynamic and has to be obtained from databse. He can click on a button to open a pop up window(generate.jsp) which gets all the new and old details from the database and displays in the pop up jsp(generate.jsp). But the main window should be customer.jsp at the background.

I am able to get the details in the same page itself, but giving the details in the pop up window with the main window at the back, I couldnt do it. Any suggestions are welcome. I am just using

in my main page(customer.jsp) to open the new window.

Thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The window.open() function is Javascript and gets called on the client (browser). When it opens, the browser makes a new request. What goes in it will be rhe results of that new request.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
Ben,
thanks for the reply. Actually I found a solution which will work for me, though I couldnt find a way to open a pop up from a servlet.

The response from the servlet comes to the jsp page and in the jsp page I am using onLoad method in the body tag. The onLoad method checks for a particular string. If the string is equal to the value I am checking, the pop up window opens.

If anyone wants still mroe details, I would be happy to provide.

Thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by vjy chin:
Ben,
I couldnt find a way to open a pop up from a servlet.

Servlets live on the server. You can't open a popup from the server.
What you are doing is perfect.
You are opening the popup from the client, with client-side code, Javascript.
vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
Thanks dude. Its good that its working. Thats the ultimate thing.

Thanks once again for the help
Srinivas Reddy Patelu
Greenhorn

Joined: May 06, 2005
Posts: 5
In your customer.jsp, call something like browse details(java script call)

<script language="javascript" type="text/javascript">

function callBrowseHierarchy(){
window.open("<%=contextpath%>/action.do","Browse","left=600,top=450,width=350,height=160,toolbar=0,resizable=0");
}

This will make a call to action class. Action class will thorow your generate.jsp as pop up window.

Thanks
tarun saha
Greenhorn

Joined: Mar 23, 2010
Posts: 27
vjy chin wrote:Ben,
thanks for the reply. Actually I found a solution which will work for me, though I couldnt find a way to open a pop up from a servlet.

The response from the servlet comes to the jsp page and in the jsp page I am using onLoad method in the body tag. The onLoad method checks for a particular string. If the string is equal to the value I am checking, the pop up window opens.

If anyone wants still mroe details, I would be happy to provide.

Thanks


Hi ben,
I have a same requirement as yours but slightly different. I have to get to the popup and back to same action class to fulfill the steps.

So its like:
1. Display the jsp.
2. On submit go to processAction.
3. fetch required details.
4. forward to a popup.
5. get data from popup.
6. update the db from processAction.

So I have to make two transits from the UI to server and back twice.

Any Idea how I can perform that?

Thanks in advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

As already stated, this cannot be handled from the server or the servlet. Popups are controlled on the client with JavaScript.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Krish Khan
Ranch Hand

Joined: Dec 14, 2009
Posts: 46
Srinivas Reddy Patelu wrote:In your customer.jsp, call something like browse details(java script call)

<script language="javascript" type="text/javascript">

function callBrowseHierarchy(){
window.open("<%=contextpath%>/action.do","Browse","left=600,top=450,width=350,height=160,toolbar=0,resizable=0");
}

This will make a call to action class. Action class will thorow your generate.jsp as pop up window.

Thanks



Srinivas can i know what will be the contextpath?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

The context path is the prefix that identifies the web app on the server. Be sure to use the EL, not scriptlets.
Krish Khan
Ranch Hand

Joined: Dec 14, 2009
Posts: 46
Thanks!


I got it.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Srinivas Patelu , thanks .

Save India From Corruption - Anna Hazare.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Opening Pop up WIndow from action class
 
Similar Threads
Saving HTML file
open a popup window of a pop up window from the parent window
opening popup window conditionally
How to give the Target of pop-up window form as a frame in the main window
opening popup window conditionally