• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Accessing session using hyperlink rather than submit button inside a JSP  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Denis St-Amour
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set the form method to "get", and submit the form under script control when the link is clicked.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!