You need to understand that JSP/JSTL runs in webserver and that JavaScript runs in webbrowser.
In order to be able to send a redirect from the webserver, you need to have a HTTP response. In order to have a HTTP response, you have to retrieve a HTTP request. In order to have a HTTP request, the client has to send it somehow; by clicking a link, submitting a form, changing the URL in browser's address bar, executing JavaScript window.location
, executing JavaScript XMLHttpRequest
, etc.
In other words, you can't send a redirect using JSP/JSTL without that the client has sent a HTTP request in some way. So, it's end of story.
Your JavaScript approach is really the best you can get to achieve the concrete functional requirement. I do therefore not understand your aversion against it and that you need to replace it by JSP/JSTL. Are you sure that you aren't confusing "JSP scriptlets" with "JavaScript"? The former is indeed a bad way of writing JSPs, but that's definitely not the same as JavaScript.