Java SessionID: How to get the Name of the GET SessionID Parameter?

it seems that the Parameter-Name in the GET request, that represents the SessionID (like jsessionid=XXXXXXXXXXXXXXXXXXXXXXXXXX in Tomcat) is not standardized in the servlet-spec? How can I get the (Servelt Container Specific) name of the SessionID? (At least in Websphere there seems to be the possibilty to change the name of the SessionID-Parameter-Name)

=> The underlaying problem is, I need to encode a URL in a servlet ALWYAS with the session ID. But it seems that the "response.encodeURL()" Method only does this if Cookies are disabled (=>therefor using URL-Rewriting with the sessionID in the URL).

What would be an alternative to always encode a URL with a session ID in a servlet? As the first question implies I wanted to build the sessionid on my own but I therefore need the sessionID-Parameter Name that however seems not be be standardized, so I somehow need to get the Parameter-Name from somewhere...)

UPDATE: The intention is to keep the SessionManagement Functionality provided by the Servlet-Container and not turn it off completely. I need to pass a Callback URL to a third party system that I want to always contain the SessionURL. So I only want to encode this single URL always with the sessionID to minimize any security issues...

Thank you very much Jan

-------------Problems Reply------------

The jsessionid isn't actually a request parameter, it's encoded on to the URL itself, and then decoded and removed by the container before it gets as far as your controller. The value of jsessionid itself can be retrieved from HttpSession.getId().

If you want to stop Tomcat from using cookies, then you can provide a tomcat-specific context.xml file under WEB-INF, containing something like this:

<Context cookies="false" path="/path/to/my/webapp">

This will disable all cookies for that webapp, and tomcat should then automatically encode all session IDs on to the URL instead.

Category:java Views:1 Time:2009-11-12

Related post

  • Java: use generics in method return that differs from generic class parameter 2010-06-28

    class SomeClass<E> { Map<String, String> someMethod(); } And usage SomeClass a = new SomeClass(); a.someMethod().get("foo") // returns object, not string! //This code would not even compile String s = a.someMethod().get("foo"); But if I r

  • java spring mvc custom tag input text value as a ModelAttribute parameter of a form 2012-03-12

    I am using java and spring mvc and I am new in it. I have just created custom tag that contains input text. Now I want to use this custom tag inside a form. This form should be passed to the controller as a ModelAttribute parameter. The custom tag do

  • Why does Java's Hashtable's get method take an Object as a parameter? 2009-11-04

    Possible Duplicate: What are the reasons why Map.get(Object key) is not (fully) generic From the JDK Documentation, the put method: public V put(K key, V value) but, the get method: public V get(Object key) Any ideas? Note: In some code I inherited,

  • How can I create Java web service (jax-ws) with array or List as a parameter 2010-12-09

    I've got a problem with web service wich has array or List as parameter. Here is example: @WebMethod public String printList(@WebParam(name = "list") List<String> list) { String result = ""; if(list == null) { result = "list is null"; } else if

  • How do you extend the Java Exception class with a custom exception that takes a String parameter? 2011-09-22

    So I see you can extend the Exception class like so: public FooException(Exception e) { this.initCause(e); } But what if you want to pass not an exception to FooException's constructor - but a String: public FooException(String message) { // what do

  • Need to know some basics of LinkedList class in Java 2009-03-10

    package abc; class DependencyDataCollection { private int sNo; private String sessionID; private int noOfDependency; private int noOfRejection; private int totalValue; /** Creates a new instance of DependencyDataCollection */ public DependencyDataCol

  • Accessing Magento API with Java : Procedure ххх not present 2010-06-15

    I need to build Special Java Api to wrap Magento Api. After struggling with several Magento bugs, I am finally able to login and get session id; but any method I call leads me to an error. The error is: Procedure '*procedure name*' not present I gene

  • Parsing JSON to Java POJO's using GSON 2010-10-16

    I have a very straight forward issue here. I need to take JSON coming from the API and convert it to objects I created for them. This far, it will deserialize them into my List but each Metric object has null values JSON COMING IN { "metrics": [ { "m

  • Send post to java servlet using C# HttpWebRequest 2011-01-27

    I have task of uploading file to java servlet. I installed Fiddler to see where web requests are sent and what post data is sent. After logging into java servlet using HttpWebRequest GET method I receive in cookies SessionId. So I was using this Sess

  • What's the nearest substitute for a function pointer in Java? 2008-09-23

    I have a method that's about ten lines of code. I want to create more methods that do exactly the same thing, except for a small calculation that's going to change one line of code. This is a perfect application for passing in a function pointer to r

  • Java - Common Gotchas 2008-10-04

    In the same spirit of other platforms, it seemed logical to follow up with this question: What are common non-obvious mistakes in Java? Things that seem like they ought to work, but don't. I won't give guidelines as to how to structure answers, or wh

  • Multi java processes by jvm? 2009-07-01

    If I want to run several processes in the same jvm without synchronizing (I don't care about multi things running at the same time... I only want to avoid re-instanciating the jvm), what is the best solution ? Starting one thread and joining to wait

  • Typically, what does it mean when java returns a "The parameter is incorrect" 2009-07-30

    I am creating a file like so try { File file = new File(workingDir, obj.getName() + ".xls"); outputStream = new FileOutputStream(file); } catch (FileNotFoundException ex) { ex.printStackTrace(); } And I am getting ..\a\

  • Passing pointers between C and Java through JNI 2009-10-27

    At the moment, i'm trying to create a Java-application which uses CUDA-functionality. The connection between CUDA and Java works fine, but i've got another problem and wanted to ask, if my thoughts about it are correct. When i call a native function

  • Get generic type of java.util.List 2009-12-21

    I have; List<String> stringList = new ArrayList<String>(); List<Integer> integerList = new ArrayList<Integer>(); Is there a (easy) way to retrieve the generic type of the list? --------------Solutions------------- If those are

  • Excel POI 3.5 WorkBook Java Heap Space Exception? 2010-01-29

    I am using the latest POI 3.5 for Excel reading . I have Excel MS office 2007 installed and for that poi is providing XSSF for executing the data. For 15000 lines of data it is executing properly, but when exceeding the limit till 30000 or 100000 or

  • Implementing unsafe Java interfaces 2010-02-13

    I've ran into a problem recently while developing with Spring Security. It has an interface GrantedAuthority with following signature: public interface GrantedAuthority extends Serializable, Comparable And as for Java 1.5 and later, the interface Com

  • How to store a file on a server(web container) through a Java EE web application? 2010-04-18

    I have developed a Java EE web application. This application allows a user to upload a file with the help of a browser. Once the user has uploaded his file, this application first stores the uploaded file on the server (on which it is running) and th

  • Java reference storage question 2010-05-22

    In java, when you pass an object to a method as a parameter, it is actually passing a reference, or a pointer, to that object because objects in Java are references. Inside the function, it has a pointer to that object which is a location in memory.

Copyright (C), All Rights Reserved.

processed in 0.139 (s). 11 q(s)