aspose file tools*
The moose likes JSP and the fly likes Refresh everything in jsp and start over Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Refresh everything in jsp and start over" Watch "Refresh everything in jsp and start over" New topic
Author

Refresh everything in jsp and start over

yudi raj
Greenhorn

Joined: Nov 11, 2011
Posts: 12
I am writing a jsp code where it displays cities upon selecting a state, which is through JDBC. I have placed a start over button in the end so that I could start the page again from the beginning. Is there anyway we could do this? Please let me know how i would approach. I tried removing attributes but that doesn't seem to be the solution. Any solution is appreciated. Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61201
    
  66

Just reload the window. That will reset everything to its initial state.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
yudi raj
Greenhorn

Joined: Nov 11, 2011
Posts: 12
Thanks for the reply Bear.
I tried reloading the window through javascript like the one below:

I am actually using Websphere Portal on JSR 168 API. After clicking on the button above, I get the error from the server console as:

"WARNING: Cannot set header. Response already committed."

I tried to invalidate the session and redirect the page back to the jsp (now assuming all the session attributes were gone). But upon running and clicking on that button, the browser displays "Page cannot be found". I have set up a button at the end of my jsp saying "Start Over" so that upon clicking on that button, I should get the page as I first loaded from the server. I tried removing attributes but that doesn't seems to be the solution. I am new to programming so please bear with me if this looks stupid to you. Any reply is appreciated. Thank you.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61201
    
  66

"WARNING: Cannot set header. Response already committed."

That's a sign of poor practices on the server.

Is there Java code in the JSP?
yudi raj
Greenhorn

Joined: Nov 11, 2011
Posts: 12
Its a long code. This is how it works:
I click on a state, and the page displays its related cities.
I click on a city and it displays their zip codes.
I click on a zip code and it displays the temperature for all days.
I just made the connection and linked these tables with the help of SQL. I am not retreiving actual temperature.
In the end, I have a Start Over button. Upon clicking it, the page should redirect me to enter the state again (from beginning)

Here is my state.jsp code


And here is my Portlet class




I know its a very long code. If I don't get a reply on this, its fine because nobody wants to waste their time reading a long code. If you do, I would really appreciate your help.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Refresh everything in jsp and start over