You could either make a round-trip to the server to have the
JSP re-write the page, or, if all the necessary data is at your disposal, you could do it all with Javascript on the client side. Or, you could use a combination Ajax approach.
Which makes more sense for your situation?