HttpSession & HttpRequest
i have imported teh following packages.
import java.io.*;
import java.util.*;
import java.lang.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.jsp.JspWriter;
but i m still getting the following error. ::
symbol : class HttpSession
location: class tcs.BulkSmsFunctions
public void display(JspWriter out, HttpSession session, HttpRequest request) th
rows IOException
^
BulkSmsFunctions.java:487: cannot resolve symbol
symbol : class HttpRequest
location: class tcs.BulkSmsFunctions
public void display(JspWriter out, HttpSession session, HttpRequest request) th
rows IOException
what could be the problem. i have copied my servlet.jar file to the C:\java\jre\lib. i had to do it for JspWriter. so wat could be the problem.
please help.
i have copied my servlet.jar file to the C:\java\jre\libWrong.
Anyway, if you talk about non-standard classes and methods which we do not have at our hand, please post a small demo code that is generally compilable, runnable and could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html and this wiki.
Similar Messages
-
Displaying HttpRequest Parameter in UIX page
Hi team,
On one page I select a value from a dropdown list - this gets saved as a request parameter on the sessionData (standard behaviour).
16:06:57 DEBUG (JhsActionServlet) -Parameter Shipment: 121What I want to do is refer to that value in a subsequent UIX page. I thought that I would be able to use
<dataObject select="Shipment" source="jheadstart:sessionData"/>but it returns null. Also, using a custom handler, I can access the value by using
String shipmentId = sessionData.getRequestParameter("Shipment");
or
String shipmentId = sessionData.getAttribute("Shipment",true).toString();
but not
String shipmentId = sessionData.getAttribute("Shipment").toString();The last returns a NullPointer exception - which is no doubt why no value is displayed on my UIX page. How come using the overloaded version of the getAttribute method("Shipment",true) works but not just ("Shipment"). I thought the standard method is supposed to check in all locations (HttpSession, HttpRequest and ServletContext) anyway ??
Also, what databinding do I need in my UIX page to access this "Shipment" request parameter.
Many thanks,
BrentBrent,
Apart from what the standard method is supposed to do, is the difference that getAttribute(String, boolean) with boolean="true" not only checks the session but also the request itself (that's where the boolean is for). The getRequestParameter() only checks the request. That is why getAttribute("Shipment", true) and getRequestParameter() both get the value, while getAttribute("Shipment") doesn't.
The request parameter is not automatically stored as a data object. You could do this using a custom action that retrieves the parameter using e.g. getRequestParameter(), create a UIX data object based on that and put that on the session. Than you can refer to it in a next page using getAttribute().
Having said this, I wonder if there is not a much simpler method to retrieve request parameters from the session. If I were you, I would post these same question on the JDeveloper forum to see if that is possible.
HTH, Jan Kettenis
JHeadstart Team -
Hey Guys
I'm trying to find a way to get multiple values using the following method
HttpSession.getAttribute(java.lang.String)
Here's the scenerio. Its a already written application and now i'm trying to make some changes. earlier in the jsp page a combo box was used and value was retrieved in the servlet using the getAttribute method of Session. Now I'm using a html multiple selection list and have to retrieve all the values selected in the list in the servlet. Can anyone please suggest me how to do that. HTTPRequest class has a method getParameterValues which will let me do that but i have to do is using HTTPSession.
Thanks for your time to read thisI'm not sure what you are trying to do. You can only use session.getAttribute to retrieve something that has already been stored in the session with a previous setAttribute. If you need to store multiple values under one attribute name using setAttribute, you can store an array, or an ArrayList or whatever type of Collection you want. The request.getParameterValues method is the only way you can retrieve form parameters than can have multiple values. If the servlet hasn't already processed these parameters and put them into the session for you, you have to use request.getParameterValues.
-
Authorized Users for J2EE's Deploytool and HttpSession queries!!
Hi guys,
i need some information about HttpSession, and J2EE's deploytool. First, i know how to use deploytool from the J2EE tutorial and it a good one but my assignment requireds more than that. I would like to know how to allow only authorized user to use an jsp(very impt jsp, that means).
Secondly, my servlet had set some attributes on a HttpSession so to forward to a jsp so I requires some session tracking. But when the user click on the 'Back' button on the I.E. The information remains there. I tried to set attribute on a HttpRequest but my jsp fails to get the information. This problem really pull me back. :-(
I really appreciate if there is any links or more advanced J2EE tutorials so i can visit them and solved my problems. Examples are welcome toooo. Thanks guys!!try http://jakarta.apache.org/struts for some
sophisticated examples.
and for setting an attribute on a request. This only
works when transferring from one servlet to another
without sending anything to the browser. Requests are
stateless, so if you set an attribute, the next time
it will not be there, since it is not saved. If you
want to save user information you can:
- create a hidden field on a form and put the
information there
- set the information you want to save in a cookie
- set the information you want to save in the session
object. -
HttpRequest.getSession(boolean create) is broken in WL 5.1
fix should be in sp6.
ISSUE 31384: Using request.getSession(false) when there is no current session was creating a new session.
"Ashish Gupta" <[email protected]> wrote:
>
>I am also getting the same problem.
><%@ page session="false" isthreadsafe="no" errorpage="error_page.jsp" %>
>HttpSession session = request.getSession(false);
>returns a valid session instead of 'null' both on WLS5.1 and WLS5.1 sp5 .
>I didn't see any reply from anyone at bea so am posting this. hope to see some acknowledgement and resolution.
>ashish
>
>
>"Ben Lindsey" <[email protected]> wrote:
>>Does anyone know if this issue has been resolved? I am currently using WLS
>>5.1 SP 5 and my JSP always creates a session even if session="false".
>>
>>Graham Johnson <[email protected]> wrote in message
>>news:[email protected]...
>>> The method
>>>
>>> public HttpRequest.getSession(boolean create)
>>>
>>> seems to be broken in WebLogic 5.1 (SP3). It works fine in 4.5.1.
>>>
>>> It appears to ignore the create flag an always creates and returns a
>>> session, instead of (from the JavaDoc):
>>>
>>> "If create is false and the request has no valid
>>> HttpSession, this method returns null."
>>>
>>>
>>> The following simple JSP illustrates the problem. Run it from a newly-
>>> opened browser and you'll get different results between 4.5.1 and 5.1:
>>>
>>> <%-- ================================================ --%>
>>> <%@ page session="false" %>
>>>
>>> <%= request.getSession(false) %>
>>> <%-- ================================================ --%>
>>>
>>> In 4.5.1 you'll get a blank page (because request.getSession(false)
>>> returns null). In 5.1 you'll get something like:
>>>
>>> weblogic.servlet.internal.session.MemorySession@45fde0
>>>
>>> meaning a session was created and attached to the request, when it
>>> shouldn't have been.
>>>
>>>
>>> --
>>> Graham K Johnson
>>> [email protected]
>>> Java Software Engineer
>>> Achieve Communications, Inc.
>>> Broomfield, CO
>>
>>
>
-
How: back-to-back HttpRequest, same client
I'm wondering if anyone has seen this on OC4J 902 or??
I have a log4j log at the top of our UseCaseHandler.jsp
and I log the HttpSession id, the client IP addr.
I'm seeing intermittant back to back HttpRequests, less than
150 ms apart. How could this happen if the user is not double
clicking the submit?
The client box is: Win95 / Win98 with IE 5.5 sp2. The client is out on a frame relay WAN. No history of TCP/IP problems that would double deliver TCP content, just that the latency is a little higher than a local LAN.
We can't double click in our test env and reproduce this?
Thanks, curtHi,
Please post the exact HP product number for your PC.
You have two options if you didn't do a clean installation:
Use the set of HP recovery disks that you created
Use the HP recovery partition if it is still intact (you may have to set the recovery partition active)
This posted MS article also will give you some more suggestions depening on your situation.
HP DV9700, t9300, Nvidia 8600, 4GB, Crucial C300 128GB SSD
HP Photosmart Premium C309G, HP Photosmart 6520
HP Touchpad, HP Chromebook 11
Custom i7-4770k,Z-87, 8GB, Vertex 3 SSD, Samsung EVO SSD, Corsair HX650,GTX 760
Custom i7-4790k,Z-97, 16GB, Vertex 3 SSD, Plextor M.2 SSD, Samsung EVO SSD, Corsair HX650, GTX 660TI
Windows 7/8 UEFI/Legacy mode, MBR/GPT -
Httpsession problem on windows 2000 nt sp3(session track)
I set up the weblogic 6.1 sp3 on the windows nt 2000 sp3.
I put the two jsp(t1.jsp, t2.jsp) at the default web.
t1.jsp:
<%
HttpSession ses = request.getSession(true);
out.println("id1:"+ses.getId());
%>
test
t2.jsp:
<%
HttpSession ses = request.getSession(true);
out.println("id2:"+ses.getId());
%>
When I link the t1.jsp from the localhost, the session id1 and id2 are the
same.
But I link the t1.jsp from the remote and use IE6 sp1, the session id are
not the same.
However I use Opera browser from the remote to link t1.jsp, the session id1
and id2 are the same.
Is this the bug for windows nt 2000 sp3 or IE6 sp1?I have the exact same symptoms on a Win2000 Pro development machine. fails at ifsmount,same as you...
-
Problem with HttpURLConnection and HttpSession.
Hi,
Problem with HttpURLConnection and HttpSession.
I created a HttpSession object in my main class and then called a URL via HttpURLConnection.
I tried to access the same session object from the servlet called by the URL . but the main session
is not returned a new seperate session is created.let me know how can we continue the same session in
the called URL also which is created in main class.
Thanks
PrasadYou are not supported to create a HttpSession by java client. Only J2EE web container can create it.
-
ERROR attempting to call HttpSession.invalidate () in TOMCAT 5.5.9
Can someone help me with this TOMCAT issue:-
I am attempting to implement a logout method that will invalidate the current session and redirect to the login page (based on SRLogout demo eg).
The code works fine in JDeveloper Embedded OC4J Server, but when i deploy the application to Tomcat 5.5.9 it throws an exception that the Session has already been invalidated.
I also notice that When i print the session object in JDev it is: 'HTTP Session ac104af6231ccf2bd0e9a39148c5adc1ea2714432a9e' but in Tomcat it is : 'org.apache.catalina.session.StandardSessionFacade@bfb545'
See the method below and exception below :
public String logoutButton_action() throws IOException{
ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContex();
HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
HttpSession session = (HttpSession)ectx.getSession(false);
session.invalidate();
response.sendRedirect("Login.jspx");
return null;
Exception
[2006-07-18 11:31:01] [ERROR] [http-8080-Processor23] (com.sun.faces.lifecycle.InvokeApplicationPhase:80) - #{backing_app_SRLogout.logoutCommandButton1_action}: javax.faces.el.EvaluationException: java.lang.IllegalStateException: getAttribute: Session already invalidated
javax.faces.FacesException: #{backing_app_SRLogout.logoutCommandButton1_action}: javax.faces.el.EvaluationException: java.lang.IllegalStateException: getAttribute: Session already invalidated
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
at oracle.adf.view.faces.component.UIXCommand.broadcast(UIXCommand.java:211)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
...After a lot of investigation, code review and tests, I finally managed to understand what's going on with this problem.
The following stack trace is the key:
java.lang.IllegalStateException: getAttribute: Session already invalidated
org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:1077)
org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessionFacade.java:110)
oracle.adf.share.http.HttpUtil.getAttribute(HttpUtil.java:98)
oracle.adf.share.http.HttpSessionScopeAdapter.get(HttpSessionScopeAdapter.java:240)
oracle.adf.share.statemanager.StateManagerScopeAdapter.<init>(StateManagerScopeAdapter.java:88)
oracle.adf.share.http.HttpStateManagerScopeAdapter.<init>(HttpStateManagerScopeAdapter.java:51)
oracle.adf.share.http.ServletADFContext.getStateManager(ServletADFContext.java:254)
oracle.adf.share.statemanager.StateManagerScopeAdapter$ADFScopeListenerImpl.scopeInvalidated(StateManagerScopeAdapter.java:251)
oracle.adf.share.ADFScopeHelper.fireScopeInvalidated(ADFScopeHelper.java:53)
oracle.adf.share.http.HttpSessionScopeAdapter.invalidate(HttpSessionScopeAdapter.java:265)
oracle.adf.share.http.HttpSessionScopeAdapter.valueUnbound(HttpSessionScopeAdapter.java:324)
org.apache.catalina.session.StandardSession.removeAttributeInternal(StandardSession.java:1686)
org.apache.catalina.session.StandardSession.expire(StandardSession.java:801)
org.apache.catalina.session.StandardSession.expire(StandardSession.java:644)
org.apache.catalina.session.StandardSession.invalidate(StandardSession.java:1158)
org.apache.catalina.session.StandardSessionFacade.invalidate(StandardSessionFacade.java:150)
oracle.adf.share.http.HttpSessionScopeAdapter.valueUnbound(HttpSessionScopeAdapter.java:324)*
org.apache.catalina.session.StandardSession.removeAttributeInternal(StandardSession.java:1686)*
org.apache.catalina.session.StandardSession.expire(StandardSession.java:801)*
catalina first invalidate the session by setting expire property to true
then it removes all attributes by calling removeAttributeInternal()
which calls whatever attributes valueUnbound method...
in this case, oracle's HttpSessionScopeAdapter try to get an attribute on the session
org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessionFacade.java:110)
oracle.adf.share.http.HttpUtil.getAttribute(HttpUtil.java:98)
catalina does not permit accessing the attributes when it is invalidated... so you get the mighty java.lang.IllegalStateException: getAttribute: Session already invalidated exception...
the solution to this problem is to remove oracle attributes BEFORE invalidating the session. This should work in any appserver implementation.
For example, in our case, the oracle attribute was a scope attribute (HttpStateManagerScopeAdapter in our stack trace)... We found those attributes using the
HttpSession.getAttributeNames() method, and removed them manually before invalidating the session.
session.removeAttribute("ORA_adf_sessionScope");
session.removeAttribute("__adf_session_scope__");
// remove private attributes
// and invalidate the session
session.invalidate();
I think that it makes sense that catalina invalidates the session before any call to the listeners, because any problem in those attributes could mean an improperly invalidated session...
Cheers. -
Could not replicate HttpSession in OC4J
Hi.
I have 2 OC4J containers version 10.1.3 in standalone mode-No AplicationServer, just the containers- that i need to cluster to do httpsession replication with peer to peer.
I've put in the j2ee/home/config/application.xml file for
AppServer1:
<cluster>
<protocol>
<peer start-port="7900" range="3" timeout="6000">
<node host="ip_of_AppServer2" port="7900" />
</peer>
</protocol>
</cluster>
in AppServer2:
<cluster>
<protocol>
<peer start-port="7900" range="3" timeout="6000">
<node host="ip_of_AppServer1" port="7900" />
</peer>
</protocol>
</cluster>
The problem is that i cannot get the two containers to replicate the httpsession.
I start the server with
java -Dhttp.cluster.debug=true -Dhttp.session.debug=true -Dcluster.debug=true -jar oc4j.jar
I get the following eror:
06/11/02 17:53:29 [ERROR] ClientGmsImpl - -handleJoin() should not be invoked on an instance of org.jgroups.protocols.pbcast.ClientGmsImpl
06/11/02 17:53:29 [ERROR] GMS - -class org.jgroups.protocols.pbcast.ClientGmsImpl.handleJoin(192.168.16.90:7900) returned null: will not be able to multicast new view
while at first it says:
06/11/02 18:04:07 [INFO] ConnectionTable - -created socket to 192.168.16.56:7900 --the ip of the other server
06/11/02 18:04:07 [INFO] ConnectionTable - -input_cookie is bela
06/11/02 18:04:07 [INFO] ConnectionTable - -created socket to 127.0.0.1:7900
The 192.168.16.90 is the ip of the server that i'm on seeing this message. I guess it tries to put itself in the cluster.
The session however is not getting replicated.
Ok so i tried just to see if it works doing the httpsession replication in the database.
<cluster>
<database data-source="jdbc/DASGGERRE"/>
</cluster>
I gave the connection a dummy name that is for sure not in the datasources file. No errors are being reported it's as if this setting is altogether ignored.
Any help would be grately apreciated,
Serban Balamaci.Hi Steve,
It must have been what you said. I had done a clean install and it worked with no problems. Well, actually I've got a really big problem. I have a simple session counter program. After a few clicks on the first server i get:
Server1:
06/11/06 15:44:06 FINE: JGroupHttpSession.beginRequest ClusteredHttpSession.beginRequest()
06/11/06 15:44:06 FINE: JGroupHttpSession.attributeModified attribteModified -- counter newValue: 14 oldValue 13
06/11/06 15:44:06 FINE: JGroupHttpSession.endRequest ClusteredHttpSession.endRequest(), accessed=true, modified=true
06/11/06 15:44:07 FINEST: Manager.reapReplicas reaped 0 replicated sessions
06/11/06 15:44:07 FINEST: Manager.reapReplicas reaped 0 replicated sessions
06/11/06 15:44:11 FINE: JGroupHttpSession.beginRequest ClusteredHttpSession.beginRequest()
06/11/06 15:44:11 FINE: JGroupHttpSession.attributeModified attribteModified -- counter newValue: 15 oldValue 14
06/11/06 15:44:11 FINE: JGroupHttpSession.endRequest ClusteredHttpSession.endRequest(), accessed=true, modified=true
06/11/06 15:44:11 FINE: JGroupHttpSession.beginRequest ClusteredHttpSession.beginRequest()
06/11/06 15:44:11 FINE: JGroupHttpSession.attributeModified attribteModified -- counter newValue: 16 oldValue 15
06/11/06 15:44:11 FINE: JGroupHttpSession.endRequest ClusteredHttpSession.endRequest(), accessed=true, modified=true
06/11/06 15:44:11 FINE: JGroupHttpSession.beginRequest ClusteredHttpSession.beginRequest()
06/11/06 15:44:11 FINE: JGroupHttpSession.attributeModified attribteModified -- counter newValue: 17 oldValue 16
06/11/06 15:44:11 FINE: JGroupHttpSession.endRequest ClusteredHttpSession.endRequest(), accessed=true, modified=true
06/11/06 15:44:38 FINEST: Manager.reapReplicas reaped 0 replicated sessions
06/11/06 15:44:38 FINEST: Manager.reapReplicas reaped 0 replicated sessions
On the same time, on Server2, i get:
06/11/06 18:38:50 FINEST: SessionReplica.applyDelta Applied 1 puts and 0 removes
06/11/06 18:38:50 FINEST: AbstractGroup.dispatch dispatching message: ApplyDelta- - 7f00000122b7be6fe46d3b144d7585fda5865557535e
06/11/06 18:38:50 FINEST: SessionReplica.applyDelta Applying put: counter value: [B@cd75d9
06/11/06 18:38:50 FINEST: SessionReplica.applyDelta Applied 1 puts and 0 removes
06/11/06 18:38:51 FINEST: AbstractGroup.dispatch dispatching message: ApplyDelta- - 7f00000122b7be6fe46d3b144d7585fda5865557535e
06/11/06 18:38:51 FINEST: SessionReplica.applyDelta Applying put: counter value: [B@f4388b
06/11/06 18:38:51 FINEST: SessionReplica.applyDelta Applied 1 puts and 0 removes
06/11/06 18:38:51 FINEST: AbstractGroup.dispatch dispatching message: ApplyDelta- - 7f00000122b7be6fe46d3b144d7585fda5865557535e
06/11/06 18:38:51 FINEST: SessionReplica.applyDelta Applying put: counter value: [B@1ac5211
06/11/06 18:38:51 FINEST: SessionReplica.applyDelta Applied 1 puts and 0 removes
06/11/06 18:38:51 FINEST: AbstractGroup.dispatch dispatching message: ApplyDelta- - 7f00000122b7be6fe46d3b144d7585fda5865557535e
06/11/06 18:38:51 FINEST: SessionReplica.applyDelta Applying put: counter value: [B@4000e7
06/11/06 18:38:51 FINEST: SessionReplica.applyDelta Applied 1 puts and 0 removes
06/11/06 18:38:52 FINEST: Manager.reapReplicas reaped 1 replicated sessions
06/11/06 18:38:52 FINEST: Manager.reapReplicas reaped 0 replicated sessions
06/11/06 18:39:02 FINEST: AbstractGroup.dispatch dispatching message: ApplyDelta- - 7f00000122b7be6fe46d3b144d7585fda5865557535e
06/11/06 18:39:02 FINEST: SessionReplica$ApplyDelta.applyTo Replicated object no longer exists
06/11/06 18:39:02 FINEST: SessionReplica$ApplyDelta.applyTo Replicated object no longer exists
06/11/06 18:39:07 FINEST: AbstractGroup.dispatch dispatching message: ApplyDelta- - 7f00000122b7be6fe46d3b144d7585fda5865557535e
06/11/06 18:39:07 FINEST: SessionReplica$ApplyDelta.applyTo Replicated object no longer exists
06/11/06 18:39:08 FINEST: AbstractGroup.dispatch dispatching message: ApplyDelta- - 7f00000122b7be6fe46d3b144d7585fda5865557535e
06/11/06 18:39:08 FINEST: SessionReplica$ApplyDelta.applyTo Replicated object no longer exists
The message that gives me trouble is " Replicated object no longer exists". I guess that means that this server can no longer find the session with that session id so it can apply the modifications. If my load balancer switches to that, the app no longer sees the session and it creates a new one.
Why is the session lost? As you can see, the time beetween operations by no means suggests that the session expired.
Do not be alarmed by the different time on the servers. I will remedy that, and i assure you that they were running at the same time. In the mean time, i will switch to the broadcast method to see how it behaves, although the loosing of the session seems to be connected to another reason.
Thanks for your answer.
Message was edited by:
user540557 -
How to access httpsession in flex2
can anyone tell me how to access teh httpsession on the
serverside while using flash remoting? I heard that it can be
obtained from AMF gateway, is that true? if so, where can i find
the AMF gateway class when using mx.rpc.remoting.RemoteObject on
the client side? or i have to use the OPENAMF product on both
client and server side? any suggestion r welcom, thx a lot.hi,
to share a session attr between a portlet and a servlet, you need to access the attribute in the application scope of the portlet ...
Object o = portletRequest.getPortletSession(true).getAttribute(name, PortletSession.APPLICATION_SCOPE);you can then access the same attr from the HTTP session ...
Object o = request.getSession(true).getAttribute(name); -
Urgent: Problems with HttpSessions in weblogic 5.1
Hi,
I am work with Weblogic 5.1, Service Pack 9. I use servlets and
HttpSession together. The idea is to store shared info in the session. I
insert complex objects, which implements Serializable interface, in the
session and SOMETIMES when I try to extract this object casting the
object to the real class I encounter an Exception:
action:
permisosPortal=(EstructuraPermisosPortal)sesion.getAttribute(portal);
portal value is "pruebas"
result:
Message,
java.lang.ClassCastException:
com.administracion.modeloGestionSeguridad.EstructuraPermisosPortal
Trace,
java.lang.ClassCastException:
com.administracion.modeloGestionSeguridad.EstructuraPermisosPortal
at
com.administracion.modeloGestionSeguridad.Autenticacion.permisosAdquiridos(Autenticacion.java:41)
at
com.administracion.novedadesServlet.FormularioAltaNovedadesServlet.service(FormularioAltaNovedadesServlet.java:47)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:915)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:879)
at
weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
at
weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:365)
at
weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:253)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
I don't know where is the problemm because if I introduce a
System.out.println before this sentence it never crashes.
action:
System.out.println(sesion.getAttribute(portal).getClass().getName()+"
"+sesion.getAttribute(portal));
result:
no crash.
Could anyone help me?
Thanks.
Hi,
I am work with Weblogic 5.1, Service Pack 9. I use servlets and
HttpSession together. The idea is to store shared info in the session. I
insert complex objects, which implements Serializable interface, in the
session and SOMETIMES when I try to extract this object casting the
object to the real class I encounter an Exception:
action:
permisosPortal=(EstructuraPermisosPortal)sesion.getAttribute(portal);
portal value is "pruebas"
result:
Message,
java.lang.ClassCastException:
com.administracion.modeloGestionSeguridad.EstructuraPermisosPortal
Trace,
java.lang.ClassCastException:
com.administracion.modeloGestionSeguridad.EstructuraPermisosPortal
at
com.administracion.modeloGestionSeguridad.Autenticacion.permisosAdquiridos(Autenticacion.java:41)
at
com.administracion.novedadesServlet.FormularioAltaNovedadesServlet.service(FormularioAltaNovedadesServlet.java:47)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:915)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:879)
at
weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
at
weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:365)
at
weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:253)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
I don't know where is the problemm because if I introduce a
System.out.println before this sentence it never crashes.
action:
System.out.println(sesion.getAttribute(portal).getClass().getName()+"
"+sesion.getAttribute(portal));
result:
no crash.
Could anyone help me?
Thanks.
-
How do i get a list of httpsessions currently active in container
what is the object that i can interact with to get a listing of active httpsessions
within my application context (servlet container) at any given time? i know i
can setup a listener, is this the only way? is there now direct api?
thanks
I replied to this question in another email thread...
"Vinod Mehra" <[email protected]> wrote in message
news:<[email protected]>...
> Here is a jsp to give you an idea. Unfortunately the session timeout
> (max-inactive-interval) is not exposed in the runtime mbean. So you will
> have to hardcode it for now. If you want it be exposed please ask support
> for a patch.
>
> <%@ page import="weblogic.management.runtime.ServletSessionRuntimeMBean,
> weblogic.management.MBeanHome,
> weblogic.management.Admin,
> java.util.Date,
> java.util.Set,
> java.util.Iterator,
> weblogic.servlet.security.ServletAuthentication,
> weblogic.management.runtime.WebAppComponentRuntimeMBean"
%>
> <pre>
> <%!
> private static final long TIME_OUT = 10; // seconds
> %>
> <%
> // login as system user
> // FIXME: don't hardcode username/passwords
> ServletAuthentication.weak("system", "gumby1234", request, response);
>
> MBeanHome home = Admin.getInstance().getMBeanHome();
> if (home != null) {
> Set mbeanSet = home.getMBeansByType("ServletSessionRuntime");
> Iterator mbeanIterator = null;
> mbeanIterator = mbeanSet.iterator();
> while (mbeanIterator.hasNext()) {
> ServletSessionRuntimeMBean runtime =
(ServletSessionRuntimeMBean)mbeanIterator.next();
> WebAppComponentRuntimeMBean parent = (WebAppComponentRuntimeMBean)
runtime.getParent();
> out.print("ContextPath: " + parent.getContextRoot() +
> " LastAccessedTime: " + new
Date(runtime.getTimeLastAccessed()));
> if (hasSessionExpired(runtime)) {
> out.println(" <b>Invalidating expired session!!</b>");
> runtime.invalidate();
> } else {
> out.println(" Session is still good");
> }
> }
> }
> %>
> <%!
> private boolean hasSessionExpired(ServletSessionRuntimeMBean runtime) {
> return (runtime.getTimeLastAccessed() < (System.currentTimeMillis() -
TIME_OUT * 1000));
> }
> %>
>
> hth,
> Vinod.
>
"Randheer Gehlot" <[email protected]> wrote in message
news:[email protected]...
>
> Vinod,
> This class "ServletSessionRuntimeMBean" does'nt give you list of
all
> the active sessions in memory. Is there any class which holds list of all
active
> sessions in memory ?
>
> Thanks..
> "Vinod Mehra" <[email protected]> wrote:
> >If you have session monitoring turned on ...
> >
> >weblogic.xml:
> >
> > <container-descriptor>
> > <session-monitoring-enabled>false</session-monitoring-enabled>
> > </container-descriptor>
> >
> >... then you should be able to lookup the runtime mbeans
> >(ServletSessionRuntimeMBean).
> >
> >This is what the admin console also uses.
> >
> >--Vinod.
> >
> >"ke" <[email protected]> wrote in message news:[email protected]...
> >>
> >> what is the object that i can interact with to get a listing of active
> >httpsessions
> >> within my application context (servlet container) at any given time?
> > i
> >know i
> >> can setup a listener, is this the only way? is there now direct api?
> >>
> >> thanks
> >
> >
>
-
Help with httprequests and responses
it is my first time writing a servlet, but i need one to work with a project i'm working on. I have a class that will do all the methods on the server side of the project, but my problem now which i need to resolve, is how to get my client side app (made in flash mx) to work with my servlet and communicate the xml information i'm getting on the server back and forth.
I know that you must answer a httpRequest in the servlet, and i know this must be sent somehow from the clientside app, but i need information and help on how to get information sent in this request the right way, and also help on how to properly format a response that will work.
from what i know so far- it looks like the type of client-side app isn't important, as long as the request is sent right- so knowing that, flash and java should work fine in communication as long as flash sends a valid request and java answers it right.
could anyone help me with information and/or help about how the requests and responses send information and what code you need to write to get information (even generalized code will work)
Help would be really really appreciated.
-mikeTo get data to and from the server and client, you'll have to seriaze it at one end and deserialize it at the other end.
I don't know much about Flash MX but a java program on the client can exchange data with a servlet using the above means.
For example, to read a string from a servlet using a java program on the client, you do the following:
On the servlet:
1. set content type to 'application/x-java-serialized-object'
2. Get an output stream thus:
ObjectOutputStream outStream =
new ObjectOutputStream(response.getOutputStream());
3. Write the data and flush the stream to be sure that all content has been sent:
outStream.writeObject(myString);
outStream.flush();
On the client (java prog):
1. get a URL: URL dataURL = new URL(protocol, host, port, address)
2. connect to the URL: URLConnection connection = dataURL.openConnection();
3. for fresh results everytime, turn off caching:
connection.setUseCaches(false)
4. get an input stream:
ObjectInputStream in = new ObjectInputStream(connection.getInputStream());
5. Get your string thus:
String myString = (String) in.readObject();
This is a very simplified example (you'll have to catch exception an a reall application).
I recommend the book 'Core Servlet and JavaServer Pages' by Marty Hall
http://www.coreservlets.com -
XSQL and HttpSession object availability
Hello,
How to access the very convenient unique HttpSession unique ID?
The one we have this way within a servlet:
HttpSession session = request.getSession(true);
System.out.println(session.getId());
Thank You in advance
JRoch
nullYou can access this easily by writing a custom action handler. Here is the code for a custom action handler that sets the value of the Http Session id into a page parameter named "session-id".
import oracle.xml.xsql.*;
import java.sql.SQLException;
import org.w3c.dom.Node;
import javax.servlet.http.*;
public class GetSessionId extends XSQLActionHandlerImpl {
public void handleAction( Node rootNode ) throws SQLException {
XSQLPageRequest req = getPageRequest();
if (req.getRequestType().equals("Servlet")) {
HttpSession sess =
((XSQLServletPageRequest)req).getHttpServletRequest().getSession(true);
if (sess != null) {
req.setPageParam("session-id",sess.getId());
}Then from within your XSQL page, you can say:
<xsql:action handler="GetSessionId"/>
and then later in the page refer to the parameter named session-id to access it's value as a lexical or bind parameter.
Maybe you are looking for
-
HT202213 home sharing with different logins
I want to share certain tunes on my itunes library with my child, but not all. I have a separate account set up for her, but I can't seem to share files. Is this because we use the same computer?
-
I'm trying to write a function internal function isObscured(o: DisplayObject, p: DisplayObject): Boolean; which tells whether the given object o is partially or completely obscured by the object p. I already tried using hitTestObject and hitTestP
-
A frame with time code could not be found error
Hey all So I just started using Speedgrade with my Premiere CS6 timeline exported as EDL, all RED (R3D) footage. When I input the EDL it only loads about 50% of the clips and pops up a red box like this: So after a bit of Googling, the only solution
-
From iPad 3 to iPad Mini?
hi, i just got rid of my iPad 3. i'm planning to get an iPad Mini when the new genartion is available. i backed up my iPad 3 to iCloud. i'd like to have my (future) iPad Mini set up exactly as my iPad 3. is it possible? if somebody has any idea or ex
-
Another question before I'd change to Blackberry: I use a mail account with several alias-adresses. On Android I installed K9-Mail where I can set more identities per mail account and which also will reply with the correct mail address. That means: i