Saving User Choices
The form action is simple; all it does is set the preferred style in a cookie, reload the original page, and close the window:
Saving the Choice in ASP
Save the form action as prefs_action.asp:
Saving the Choice in Java
This form action should be saved as prefs_action.java in the classes folder, and compiled to prefs_action.class:
In this case, rather than a doGet() method, we have a doPost() method because the form was set to submit via the post method rather than the get method.
This method starts out just as before, sending the header information and creating the out PrintWriter. Next, we get the value submitted on the form using the getParameter() method, and use it to create the Cookie object. We then add the styleCookie object to the response.
The reference self.opener refers to the window object that caused this window to open. In this case, that's the main Primary Outpost window. This command causes it to set the location to the current locationin other words, to reload the page. For now, this will have no obvious purpose, but next we will add code to the main page that causes the choice to take effect.
Finally, the last command, self.close(), closes the popup window.
To see this in action, submit the form in the popup window.