Ver Mensaje Individual
  #5 (permalink)  
Antiguo 13/05/2010, 05:59
Denis127
 
Fecha de Ingreso: febrero-2010
Mensajes: 128
Antigüedad: 14 años, 2 meses
Puntos: 3
Respuesta: uso de servlets y sesiones

  1. Class javax.​servlet.​http.​HttpServletRequest

    public HttpSession getSession()
    Returns the current session associated with this request, or if the request does not have a session, creates one.

    Returns:
    the HttpSession associated with this request

  1. Class javax.​servlet.​http.​HttpServletRequest

    public HttpSession getSession(boolean create)

    Returns the current HttpSession associated with this request or, if there is no current session and create is true, returns a new session.

    If create is false and the request has no valid HttpSession, this method returns null.
    To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.

    Parameters:

    create - true to create a new session for this request if necessary; false to return null if there's no current session
    Returns:
    the HttpSession associated with this request or null if create is false and the request has no valid session


Ahora te lo cuento con mis palabras:

Sin parámetros te devuelve la sesión y si no la hay, te la crea.

Con parámetros:
  1. Si pones false, te devuelve la sesión y si no la hay te devuelve null.
  2. Si pones true, te devuelve la sesión y si no la hay crea una nueva.

Pienso que si te da error puede ser porque hayas modificado el objeto request por otro, o porque quizas hayas sobreescrito la sesión.

quizas el problema sea esta línea, que tan siguiera entiendo...
(peticion.getParameter((String)parametros.nextElem ent())).getSession(true);

Intenta olvidartedel método getSession(boolean) asi te vas a hacer un lio xk en unos casos te la crea, en otros no y en otros te da null...

cuando quieras borrar la sesión utiliza session.invalidate() y cuando quieras recuperarla haz request.getSession().

Así siempre tendrás una sesión y cuando quieras borrarla te aseguras de dónde la has borrado.

espero que con esto lo puedas arreglar...