[Logo]
Forums Register Login
Accessing session using hyperlink rather than submit button inside a JSP
Hi,

I am looking to convert a logout button inside a jsp page to a hyperlink. Is there a way to access the session using a hyperlink instead of a form? Here is what I'm trying to convert:


<form method="POST" action="myservlet">
<input type="hidden" name="requestPageName" value="<%= REQUEST_PAGE_NAME %>">
<input type="hidden" name="actionCode" value="<%= ActionConstants.NMME_LOGOFF %>">
<input type="submit" value="Logoff">
</form>

TO:

<% if (appSession.getActionCode() == ActionConstants.ULGN_LOGON) {%>
<li id="cn-cmb6"><a href="<%=APP.JSP_PATH%>login.jsp"><fmt:message key="logout" bundle="${fmtCommonMenuBar}"/></a></li>
<%}else { %>
<li id="cn-cmb6"><a href="#"></a></li>
<%}%>


As you can see I am also using bundles, so I can't use session.invalidate() because my language toggle would no longer work once I return to the login page.



I'm not sure what you mean by "access a session". Forms and links submit requests, not "access sessions".

Perhaps you can explain a bit more about what you are trying to accomplish.

Also, Java code (scriptlets) in a JSP is a practice that has been discredited for a almost a decade now. It's long passed the time to use more modern techniques such as the JSTL and EL.
What I'm trying to figure out is how to pass the actionCode value to 'myservlet' through a url instead of a form.


This is a very old application and we are in the process of trying to eliminating as much Java code in the JSPs. The code provided has not yet been converted fully.
You can set the form method to "get", and submit the form under script control when the link is clicked.
Your mother was a hamster and your father was a tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature


This thread has been viewed 1112 times.

All times above are in ranch (not your local) time.
The current ranch time is
Apr 19, 2018 08:02:09.