That made no sense.
On the server side, that's simply the only way there is to do it. You could also do it via JavaScript, but since you're in the
JSP forum, I gave the JSP-oriented answer. If you're not willing to do any research yourself, you're going to be limited to getting the answers that make the most sense based on what and how you ask.