Is Bulky Session Object Better or a Bulky Stateful Sess bean better
Hi,
We are clustering on Weblogic 6.0. Currently we are debating on whether
to cache out ACL information which is very bulky in the session object
or to store it into a statefull session bean and store the handle to
that bean in the HttpSession object
I "feel" it might be preferable to bulk the Session bean than to bulk
the HttpSession object. Weblogic documentation discourages making the
HttpSession object heavy citing replication issues. But wouldnt the same
issues arise when we store a lot of information on the Session Bean.
Also do all attributes of the Session bean need to be Serializable to
support clustering.
Any help will be appreciated.
Thanks
Sameer
Sticky -- it will continue to go back until the session or the server dies.
Peace,
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/registration.jsp >>
"Sameer Wadkar" <[email protected]> wrote in message
news:[email protected]...
> If user x makes a call to servlet Y on Machine A where Machine A and B are
in
> cluster. If the user makes a second call to Y will the proxy webserver if
thats
> what is being used redirect the user call to machine A
> and not B for sake if laodbalancing?
>
> Sameer
> Cameron Purdy wrote:
>
> > Replication uses serialization. Serialization does not take transient
> > fields. Therefore, even when used in a stateful session bean,
replication
> > would not take transient fields.
> >
> > Peace,
> >
> > --
> > Cameron Purdy
> > Tangosol, Inc.
> > http://www.tangosol.com
> > Tangosol: How Weblogic applications are customized
> >
> > "Sameer Wadkar" <[email protected]> wrote in message
> > news:[email protected]...
> > > Cameron,
> > >
> > > One last question? If I have a stateful session bean and I have an
handle
> > to
> > > it. In a clustered environment would a transient field inside a
Stateful
> > > Session bean NOT BE replicated. I understand the situation for
HTTPSession
> > > objects. I just want to confirm if the situation is treated in
identical
> > > fashion while replicating Stateful Session Beans.
> > > If I am working in a clustered environment and a client has
established an
> > > HTTPSession with respect to my server. When the client makes repeated
> > calls to
> > > the server in the context of that session is the client request
forwarded
> > to
> > > the same server each time if there is no failover or to diff servers
in
> > the
> > > cluster to meet loadbalancing req.
> > > Also what is preferable (I am now not talking of clusteringnow : just
> > > performance issues in a single server) storing a large object in
> > HTTPSession
> > > object or
> > > putting that large object in a Stateful Session Bean and storing its
> > handle in
> > > the Session object(We need that object practically everytime a
Controller
> > > Servlet fires). Weblogic guys suggested to us that the session object
> > should be
> > > kept as small as possible to which I agree hence I thought of this
> > solution.
> > >
> > > I would appreciate your response. We are using Weblogic 6.0
> > >
> > > Regards,
> > > Sameer
> > >
> > > Cameron Purdy wrote:
> > >
> > > > Sameer,
> > > >
> > > > You are joking, right? Replicating a sh?tload of stuff across a
cluster
> > is
> > > > expensive. Cached items that can be reloaded on another server in
the
> > rare
> > > > case of failover should not be replicated, since they can be
reloaded on
> > > > another server in the rare case of failover. If you want your
> > application to
> > > > perform well, don't replicate things that you don't have to!
> > > >
> > > > Here's the math:
> > > >
> > > > - 1 in pf chance of a request having to failover, where pf should be
at
> > > > least 10,000,000
> > > > - cb is the number of bytes being replicated, and f1(cb) is the cost
of
> > > > replicating
> > > > - f2(cb) is the cost of loading the cache from the database (for
> > example)
> > > >
> > > > If f2(cb)/pf is greater than f1(cb) then you should not replicate
the
> > cache.
> > > > Generally that means that if you replicate the cache, you are
expecting
> > each
> > > > server to die after serving between one and two requests. If that is
the
> > > > case, you are really hosed to begin with.
> > > >
> > > > If you have an object stored in the HTTP session, and that object
has a
> > > > transient field, the contents of the transient field are not
replicated.
> > > > That means that you can store your cache in a transient field on an
> > object
> > > > that you store in the HTTP session, and you will not pay a
significant
> > > > replication price on it. The accessor for the cache should follow
the
> > lazy
> > > > pattern such that on failover it will reload the cache.
> > > >
> > > > For even more performance, you should implement Externalizable,
since
> > you
> > > > can improve the performance of ser/deser by a factor of 3 to 10 or
so.
> > > >
> > > > Peace,
> > > >
> > > > --
> > > > Cameron Purdy
> > > > Tangosol, Inc.
> > > > http://www.tangosol.com
> > > > Tangosol: How Weblogic applications are customized
> > > >
> > > > "Sameer Wadkar" <[email protected]> wrote in message
> > > > news:[email protected]...
> > > > > How would it matter. Both the Session Bean and The Session object
are
> > > > > destriyed whrn the user logs off.
> > > > >
> > > > > Cameron Purdy wrote:
> > > > >
> > > > > > If it is just a cache, then you need to prevent it from being
> > > > replicated.
> > > > > > Use a "transient" field or implement Externalizable on that
object
> > to
> > > > > > control serialization and avoid serializing cached objects.
> > > > > >
> > > > > > Peace,
> > > > > >
> > > > > > --
> > > > > > Cameron Purdy
> > > > > > Tangosol, Inc.
> > > > > > http://www.tangosol.com
> > > > > > Tangosol: How Weblogic applications are customized
> > > > > >
> > > > > > "Sameer Wadkar" <[email protected]> wrote in message
> > > > > > news:[email protected]...
> > > > > > > Hi,
> > > > > > >
> > > > > > > We are clustering on Weblogic 6.0. Currently we are debating
on
> > > > whether
> > > > > > > to cache out ACL information which is very bulky in the
session
> > object
> > > > > > > or to store it into a statefull session bean and store the
handle
> > to
> > > > > > > that bean in the HttpSession object
> > > > > > > I "feel" it might be preferable to bulk the Session bean than
to
> > bulk
> > > > > > > the HttpSession object. Weblogic documentation discourages
making
> > the
> > > > > > > HttpSession object heavy citing replication issues. But
wouldnt
> > the
> > > > same
> > > > > > > issues arise when we store a lot of information on the Session
> > Bean.
> > > > > > > Also do all attributes of the Session bean need to be
Serializable
> > to
> > > > > > > support clustering.
> > > > > > >
> > > > > > > Any help will be appreciated.
> > > > > > >
> > > > > > > Thanks
> > > > > > > Sameer
> > > > > > >
> > > > >
> > >
>
Similar Messages
-
How to get Request/Session objects in a Webdynpro application
Hi
I am working in Enterprise Portal 7.0.
in one of the iViews which displays a JSP page, i have set a parameter in request and session objects.
How can i get it in my Webdynpro ABAP Application?
Thanks & Regards
Abhimanyu Lhi Abhimanyu
I believe originally access to session was deliberately not made available inside WDA.
Growing security concerns due to misuse of session information and
perhaps other reasons as well.
X.509 is considered a better approach.
This may not help you in your problem.
But you may see a trend in WDA pushing more robust and client independent
approaches.
Full x.509 access should remove the need for session fiddling.
Also when developers access such session info directly, there is a possiblity
when they dont understand the technology exactly that they create a security hole.
You may know how to do safely, it is however discouraged.
Im not aware of a way to get at the session info inside the WDA framework.
Well not without a mod to the framework.
It may be possible without a mod, but I dont know the trick.
If someone has a little trick... please post.
You may need to use BSP, if your only solution requires access to the session info.
regards
Phil -
Vector and session object...
Hi, I have a JSP that retrieves a resultset with 3000+ rows. I use that resultset to create a summary page of grouped data, so the resulting page is only a few lines. Each group is a link that can be double clicked to call a JSP that will display the detail line items.
From a developers viewpoint, this is how I'm doing it: On the first JSP, as I scan through the resultset creating the summary line items I add the detail data to a vector. After I'm done processing the resultset I add the vector to the session object. When the hyperlink on the first JSP is activated I call a second JSP that retreives the vector from the session object and display the results.
Is that a good idea or a bad idea? It seems to work ok, but I'm thinking it might be alot of data to be storing on a session object especially when you consider the number of users that could be on. Is there a way to compress the vector when I add it to the session object? Is there a better way to do this? Unfortunately, I can't re-retrieve the data because the SQL takes too long. Thanks!Sure you could compress it... you could use the classes in java.util.zip, and use an ObjectOutputStream plus a ZipOutputStream plus a ByteArrayOutputStream (I think), using zip compression to convert your Vector into an array of bytes, and then do the reverse when you needed the data uncompressed. Chances are that would compress your data by about 80 or 90%.
Here you would be making the classic tradeoff between memory usage and processing time; I wouldn't do this compression thing until it was clear that it was necessary, though. -
Question about app design - database + session object in JSP
hi all
i am studying this application built mostly with servlets and JSPs, and there are several questions i want to ask your guys' opinions about it.
first of all, i noticed that the application hits database to get/save data very frequently. from one page to another it would save data collected from user to the DB, and retrieve data from DB to display on the next page. it does this a lot. would this decrease the overall performance of the application, i mean a DB hit requires network traffic overhead, wouldn't it be better if all data collected from user are stored in a session object temporarily, and all the data that are displayed on those pages retrieved at the start time? and do one save process in the end. it uses Oracle DB if it makes any difference. should we try to avoid db hit as much as possible?
my next question is that is it good approach to keep information in session object? even if there is a lot of data to keep?
another question is the db connection. in a pooled environment - weblogic server, we would use JNDI in the code to get connection from the pool, we use it and close it. when we close a connection with close() method, what really happens? does this connection gets return to the pool or it is being destroyed completely.
i know this is a lot to ask, i appreciate your help very much. looking forward to seeing some feedback.No, I don't have tables of values. I have a java 1.5 enumeration, like for instance:
public enum VelocityConvention {
RELATIVISTIC,
REDSHIFT;
}and a class Velocity that contains a convention and a value like so:
public class Velocity {
public VelocityConvention getConvention() {...}
public double getValue() {...}
public void set(VelocityConvention conv, double value) {...}
}When I persist the Velocity class to the database, I want a field called convention that holds the appropriate value of the enumeration. That much is done how I explained before.
I want to have a selectOneMenu for setting the convention. Via trial and error, I found that MyFaces wasn't able to automatically convert from a string back to a proper VelocityConvention enum constant. It can, of course, convert from the enum to a string because it just calls toString(). But I need both directions for any UIInput element I use, be it a selectOne, or just a straight inputText. -
Memory limitation for session object!
what is the memory limitation for using session objects?
venuas already mentioned there is no actual memory limitation within the specification, it only depends on the jvm's settings
how different app-server handle memory management of session objects is another part of the puzzle, but in general you should not have problems in writting any object to the session.
we had the requirement once to keep big objects in session, we decided to do a ResourceFactory that returns us the objects, and only store unique-Ids into the session.
We could lateron build on this and perform special serialization tasks of big objects in the distributed environment.
Dietmar -
How to get Multiple Values for a key from a session object?
Hi,
It might seem dumb but I am facing a problem here with the session object. I'll paste the session object's content from the netbeans "Local Variables" window for clarity -
Name Type Value
hsession StandardSessionFacade #66
session LWSFSession #69
inherited
attributes Hashtable #80
[0] Hashtable$Entry "cart"=>#115
key String "cart"
value DummyCart #115
item null
submit null
v Vector
[0] String Full Metal Jacket
[1] String As Good As It Gets
[2] String Tim
What I want is to get the values "Full Metal Jacket", "As Good As It Gets" and "Tim" from the session obejct?
The problem I am facing is that if I do a session.getAttribute("cart"), I'll get a single value in return. What will that value be? Will it be "item", "submit" or "v"? And if I want all the values in v above, how can I get them?
Thanks.None of the above.
HttpSession.getAttribute() will return what you put into it using HttpSession.setAttribute(). In your case, it'll return an Object which you need to cast to DummyCart. Then you can access the data in DummyCart using the API of the DummyCart class.
hth -
Using a session object to hold the value of a record set?
Hi,
I'm trying to hold the value of a record set (or literally the content of a column in a query in a db) in a session variable so that I can call on this later and insert into another table.
I'm not sure of the correct syntax, I've already made a connection to the DB. I'm trying the following but it doesnt seem to like the code:
<% session.setAttribute("code",rs("column_name")); %>
<%String attrib =
String.valueOf ( session.getAttribute("code")); %>
Hello <%= attrib %>
Any ideas, I dont know how to reference the record set, I declared the recordset previously as rs. Help! Can't find examples anywhere on the net!So just to recap. I appear to be seeing the column name "custorderno" within the Microsoft Access query "lastcust". But I get "no data found" when I run the following code (which I have sectioned off)
<!-- connect to database and lastcust query --!>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Tomcat/jakarta-tomcat-4.1.31/webapps/ROOT/Oatcake.mdb","","");
Statement statement = conn.createStatement();
String sql = "SELECT * FROM lastcust";
ResultSet rs = statement.executeQuery(sql);
while (rs.next()) {
%>
<TR><TD><%= rs.getString("custorderno") %></TD>
</TR>
<% session.setAttribute("code",rs.getString("custorderno")); %>
<% String attrib =
String.valueOf ( session.getAttribute("code") ); %>
Hello <%= attrib %> [B]
<%
%>
</TABLE>
<%
if (statement != null)
statement.close();
if (conn != null)
conn.close();
catch (Exception e) {out.print(e);}
%>
</BODY>
</HTML>
No as mentioned I am (as you can see) declaring everything as a string when in actual fact the contents of the "custorderno" within the query is set to a autonumber within MS Access.
The while loop does work by returning the contents but the session object part is not working correctly with the following result returned:
[B]java.sql.SQLException: No Data Found
Help please! -
Hello,
We have an EJB3 application deployed to an Oracle AS 10.1.3.1.0 instance.
Our main point of entry to the application is a stateful session bean (that controls access), that has injected several other stateful session beans.
Like this:
+@Stateful(name = "TstreamUserSession")+
+public class TstreamUserSessionBean extends UserSessionBean implements TstreamUserSession {+
+@EJB(name = "ContactSession")+
private ContactSessionLocal contactSession;
+@EJB(name = "GuestSession")+
private GuestSessionLocal guestSession;
+@EJB(name = "TechCustomerSession")+
private TechCustomerSessionLocal techCustomerSession;
+@EJB(name = "PmSession")+
private PmSessionLocal pmSession;
+@EJB(name = "CustomerSession")+
private CustomerSessionLocal customerSession;
+@EJB(name = "PartnerSession")+
private PartnerSessionLocal partnerSession;
+@EJB(name = "AdminSession")+
private AdminSessionLocal adminSession;
+@EJB(name = "SuperAdminSession")+
private SuperAdminSessionLocal superAdminSession;
+@EJB(name = "VmSession")+
private VmSessionLocal vmSession;
+public TstreamUserSessionBean() {+
+}+
+...+
In this class, we also look up these sessions, because we need several instances of these, in this manner:
+private synchronized Object getSessionInstance(String sessionName) throws AccessDeniedException {+
+try {+
InitialContext ic = new InitialContext();
return ic.lookup("java:comp/env/" sessionName);+
+} catch (NamingException e) {+
+}+
+}+
However, we keep getting the following messages after a certain period.
java.io.IOException: Unable to find session object 2816103596632839360 for location 'AdminSession'
+10/01/12 11:50:04 at com.evermind.server.ejb.EJBInternalInputStream.resolveObject(EJBInternalInputStream.java:70)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.checkResolve(ObjectInputStream.java:1346)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)+
+10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.activateBean(StatefulSessionEJBObject.java:581)+
+10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.remove_X(StatefulSessionEJBObject.java:213)+
+10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.remove_X(StatefulSessionEJBObject.java:159)+
+10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBHome.processTimedOutSessions(StatefulSessionEJBHome.java:371)+
+10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBHome.cleanUpMaintenance(StatefulSessionEJBHome.java:306)+
+10/01/12 11:50:04 at com.evermind.server.ejb.EJBTask.run(EJBTask.java:47)+
+10/01/12 11:50:04 at com.evermind.util.Task.schedule(Task.java:51)+
+10/01/12 11:50:04 at com.evermind.util.TaskManager.run(TaskManager.java:221)+
+10/01/12 11:50:04 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)+
+10/01/12 11:50:04 at java.lang.Thread.run(Thread.java:595)+
I guess this occurs when the stateful session TstreamUserSession is reactivated?
Or when the ones being injected are passivated?
Any idea why this occurs, or how to suppress it, because it really spams our logs...
Thanks.Hello,
We have an EJB3 application deployed to an Oracle AS 10.1.3.1.0 instance.
Our main point of entry to the application is a stateful session bean (that controls access), that has injected several other stateful session beans.
Like this:
+@Stateful(name = "TstreamUserSession")+
+public class TstreamUserSessionBean extends UserSessionBean implements TstreamUserSession {+
+@EJB(name = "ContactSession")+
private ContactSessionLocal contactSession;
+@EJB(name = "GuestSession")+
private GuestSessionLocal guestSession;
+@EJB(name = "TechCustomerSession")+
private TechCustomerSessionLocal techCustomerSession;
+@EJB(name = "PmSession")+
private PmSessionLocal pmSession;
+@EJB(name = "CustomerSession")+
private CustomerSessionLocal customerSession;
+@EJB(name = "PartnerSession")+
private PartnerSessionLocal partnerSession;
+@EJB(name = "AdminSession")+
private AdminSessionLocal adminSession;
+@EJB(name = "SuperAdminSession")+
private SuperAdminSessionLocal superAdminSession;
+@EJB(name = "VmSession")+
private VmSessionLocal vmSession;
+public TstreamUserSessionBean() {+
+}+
+...+
In this class, we also look up these sessions, because we need several instances of these, in this manner:
+private synchronized Object getSessionInstance(String sessionName) throws AccessDeniedException {+
+try {+
InitialContext ic = new InitialContext();
return ic.lookup("java:comp/env/" sessionName);+
+} catch (NamingException e) {+
+}+
+}+
However, we keep getting the following messages after a certain period.
java.io.IOException: Unable to find session object 2816103596632839360 for location 'AdminSession'
+10/01/12 11:50:04 at com.evermind.server.ejb.EJBInternalInputStream.resolveObject(EJBInternalInputStream.java:70)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.checkResolve(ObjectInputStream.java:1346)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)+
+10/01/12 11:50:04 at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)+
+10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.activateBean(StatefulSessionEJBObject.java:581)+
+10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.remove_X(StatefulSessionEJBObject.java:213)+
+10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.remove_X(StatefulSessionEJBObject.java:159)+
+10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBHome.processTimedOutSessions(StatefulSessionEJBHome.java:371)+
+10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBHome.cleanUpMaintenance(StatefulSessionEJBHome.java:306)+
+10/01/12 11:50:04 at com.evermind.server.ejb.EJBTask.run(EJBTask.java:47)+
+10/01/12 11:50:04 at com.evermind.util.Task.schedule(Task.java:51)+
+10/01/12 11:50:04 at com.evermind.util.TaskManager.run(TaskManager.java:221)+
+10/01/12 11:50:04 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)+
+10/01/12 11:50:04 at java.lang.Thread.run(Thread.java:595)+
I guess this occurs when the stateful session TstreamUserSession is reactivated?
Or when the ones being injected are passivated?
Any idea why this occurs, or how to suppress it, because it really spams our logs...
Thanks. -
I need to add the values stored in the session object into the html textbox
Dear Sir,
i have been trying to create an edit employee details page
What i have done till now is as follow:
1. Got employee id from HTML page.
2. Compared it with the id stored in the database.
3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.
4. Dispatched the session values to another servlet EditEmpDetails2.java
what i need to do now
5. Now i need to set the session values in the text field of the html form
6. I also need to be able to edit those vales and store the edited values in the database.
Please help me as i have tried doing it for 1 week without any clues
i have tried to create a html page which is something like this:
<html>
<head>
<title>Edit Employee Details Page</title>
<body BGCOLOR="red" text="black">
<h1 ><font color="black">Edit Employee Details Page</font></h1>
<form action = "EditEmpDetails" method="Get">
<table width="50% align="center"
<tr><td>Employee ID: </td>
<td><INPUT TYPE="TEXT" name="employeeid"<br></td></tr>
<tr><td><center><input type="submit" value="submit"></center></td></tr>
<tr><td><center><input type="reset" value="reset" ></center></td></tr>
</table>
</form>
</body>
</html>
design of my servlet EditEmpDetails.java
public void EditEmpDetails1 extends HttpServlet
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
PrintWriter out = response.getWriter();
response.setContentType("text/html");
HttpSession session = request.getSession();
String employeeid;
String X = request.getParameter("employeeid");
System.out.println("Employee iD:" + X);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:murphy");
String query = "Select * from users where employeeid=?";
PreparedStatement stat = con.prepareStatement(query);
System.out.println(stat);
stat.setString(1,X);
ResultSet rs = stat.executeQuery();
while(rs.next())
String Z = rs.getString(password);
if(Z.equals(X))
String A = rs.getString(1);
session.setAttribute("employeeid", A);
String B = rs.getString(2);
session.setAttribute("firstname", B);
String C = rs.getString(3);
session.setAttribute("lastname", C);
String D = rs.getString(4);
session.setAttribute("gender", D);
String E = rs.getString(5);
session.setAttribute("dateofbirth", E);
String F = rs.getString(6);
session.setAttribute("address", F);
String G = rs.getString(7);
session.setAttribute("postalcode", G);
String H = rs.getString(8);
session.setAttribute("phone", H);
String I = rs.getString(9);
session.setAttribute("mobile", I);
String J = rs.getString(10);
String url = "/EditEmpDetao;s.java";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url)
dispatcher.forward(request,response);
catch (Exception e)
system.out.println(e)
I do not know how to put the values stored in the session object into the html text box3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.do you really need to store this in session object?
5. Now i need to set the session values in the text field of the html form which form? in a new html/jsp page? i suggest go for a JSP
In your JSP page use JSP expression tags to put the session attributes.
it's something like : <input type='text' name='employeeid' value='<%= session.getAttribute("employeeid") %>' >and you need to generateanother servlet for saving the details/modifications to the database.
I think i m clear enough.
if you need more clarifications. just try it and then post your problem.
Diablo -
How to use a Session object in a Javascript function
I have an object that I have set in my session.
On my jsp I want to pull it out of my session and use it as a parameter for a javascript function. But I am not sure how to do that... the function call is below... I want to assign a value to ifFormat (last variable in function) But I am not sure what to use inside javascript.
<script type="text/javascript">
Calendar.setup({inputField:"f_date_dfFirstPmtDate",
button:"f_trigger_dfFirstPmtDate",
singleClick:true,
ifFormat:XXXXX});
</script>Note that javascript runs on the client side, and JSP runs on the server. JSP and the session objects are NOT available to javascript in reaction to the user.
If this function is called only when the page is first created, not when the user interacts with the page, or if you want that value to be constant with respect to the javascript, then you can do this:
<%
String someValue = (String)session.getAttribute("theAttributeName");
%>
<script type="text/javascript">
Calendar.setup({inputField:"f_date_dfFirstPmtDate",
button:"f_trigger_dfFirstPmtDate",
singleClick:true,
ifFormat:<%=someVale%>});
</script> -
How to use session object in jsp
hi all
marry christmas
can anyone plz tell me how to use session obect in jsp
rachna
Message was edited by:
rachna_arora82hi rachna,
JSP has a default(implicit) session object...... use the getSession(true) method on the session object and then going u can either get or set attributes depending on the requirement
That was in general and now with the issue u have got..... what u can do is that the u can create session for every user who logs in and when he/she tries to login again then u can probably check for the existing session object in the JSP and perform the logic as required..... any clarifications plzzzzzzz let me know
Thanks n Regards
Naveen M
Message was edited by:
Novice_inJAVA
Message was edited by:
Novice_inJAVA -
How to obtain a session object from session id
Hi all,
let say that I have a list of session ids, and I want by scheduald task to check whether the session is alive\active.
I saw that the HttpSessionContext was deprecated. (see: http://javasolution.blogspot.com/2007/08/getting-session-object-using-session-id.html)
Is there any other way to check if the session is alive?Do it the other way: let the session itself notify that it is not alive anymore.
Implement a HttpSessionListener which adds the session to list/set/map on create and removes the session from it on destroy, register it in the web.xml and run it. -
How to implement a Session Object.
Hi,
If anybody show me any example of how to implement
session object so that I can store any parameters such as user id and use it later on. And also if there is any good web site for reference about using session object.
thanksYou can use the the session.setAttribute and session.getAttribute methods.
For example let's say you would want to store a username in the session after a user has logged on:
String usrname = request.getParameter("username");
session.setAttribute("myStoredUsername", usrname);
you can then retrieve it using the get method. Remember that the entities stored inside a session object are generic objects and need to be cast to be used:
String usrname2 = (String)session.getAttribute("username");
Hope this helps
Chelman -
How to validate a session object in jsp?
Hi All,
i am facing a problem.The problem is how to validate the session object object in jsp.I have written a java script by using a defined function as setInterval and has given 5 mintues if the user is idle and will show a pop up menu before time out the session but in case of page active still this pop up menu is coming. The java script as follows.
function SetTimer(){
//How long before timeout (should be a few minutes before your server's timeout
//set timer to call function to confirm update
if(timeoutMinutes)
timerObj = setInterval("ConfirmUpdate()",60000);
function clearTimerFn(){
timerCount = 0;
clearInterval(timerObj);
//timerObj = setInterval("ConfirmUpdate()",60000);
function ConfirmUpdate(){
//Ask them to extend
if(confirm("Your session is about to expire. Press 'OK' to renew your session.")){
//load server side page if ok
var url = "ajaxSessionchecker.do?sessionvalidate=sessionvalid";
LoadXMLDoc(url);
And in jsp i am calling this js function as
<%session=request.getSession(false);
if(session.getLastAccessedTime()==60000){ %>
<script type="text/JavaScript">
clearTimerFn();
</script>
<%}else{
session.setMaxInactiveInterval(-1000);} %>
could you pls help me out?The reason for doing this is when ever i come to this user.jsp from account.jsp with a different account number this user.jsp is not refreshed and i still
see the same old user.jsp for the previous account that i naviated before. Also please let me know if there is any other approach to acheive this taskDoes refreshing the page by pushing F5 solve the problem?
If so, then the browser is caching the page, despite your attempts to stop it. -
hi,
is possible obtain the session object in a class method without send it from jsp as a parameter?you mean like this?
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res)
throws Exception {
SessionManager sm = new SessionManager(req);
....sessionmanager class
package com....;
import java.util.*;
import java.lang.reflect.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
* <code>SessionManager</code> is a wrapper for request, response and session
* @author
public class SessionManager {
static Logger log = Logger.getLogger(SessionManager.class);
** Holds string containing the unique identifier assigned to this session
private String sessionid;
** Holds HttpSession object
private HttpSession session;
** Holds request object object - must be passed in by the calling application
private HttpServletRequest request;
** Holds response object - any application sending a response must call
** session manager
private HttpServletResponse response;
** Holds Servlet Context - useful if logging is reqd.
private ServletContext context;
* Page context.
private PageContext pctx = null;
** Constructor to initialize with a request object
public SessionManager(HttpServletRequest req) {
request = req;
session = req.getSession();
sessionid = session.getId();
** Constructor to initialize with a pagecontext object - convenient to call from jsp's
public SessionManager(PageContext pctx) {
request = (HttpServletRequest) pctx.getRequest();
response = (HttpServletResponse) pctx.getResponse();
context = pctx.getServletContext();
session = pctx.getSession();
sessionid = session.getId();
this.pctx = pctx;
** Constructor to initialize with request, response objects
public SessionManager(HttpServletRequest req, HttpServletResponse resp) {
request = req;
response = resp;
session = req.getSession();
sessionid = session.getId();
** Constructor to initialize with request, servletcontext objects
public SessionManager(HttpServletRequest req, ServletContext ctx) {
request = req;
context = ctx;
session = req.getSession();
sessionid = session.getId();
** Constructor to initialize with request, response and context objects
public SessionManager(HttpServletRequest req, HttpServletResponse resp, ServletContext ctx) {
request = req;
response = resp;
context = ctx;
session = req.getSession();
sessionid = session.getId();
** Setter and getter methods
public void setRequest(HttpServletRequest req) {
request = req;
session = req.getSession();
sessionid = session.getId();
** Setter and getter methods
public void setContext(ServletContext ctx) {
context = ctx;
** Setter and getter methods
public ServletContext getContext() {
return context;
public void createLoginSession(java.io.Serializable obj) {
if (obj == null)
log.debug("Object is null");
setAttribute("user", obj);
public void setAttribute(String key, java.io.Serializable obj) {
session.setAttribute(key, obj);
public void removeAttribute(String key) {
session.removeAttribute(key);
** Setter and getter methods
public HttpServletRequest getRequest() {
return request;
** Setter and getter methods
public HttpServletResponse getResponse() {
return response;
** Checks if either member session or guest session exists
public boolean isLoggedIn() {
if (session.getAttribute("user") != null)
return true;
else
return false;
public long getCreationTime() {
return session.getCreationTime();
** Setter and getter methods
public String getId() {
return session.getId();
public long getLastAccessedTime() {
return session.getLastAccessedTime();
public int getMaxInactiveInterval() {
return session.getMaxInactiveInterval();
** Setter and getter methods - also useful for retrieving state object(s)
public Object getAttribute(String name) {
if (session != null)
Object sObject = session.getAttribute(name);
//Log.debug("Session State for the object "+name+" is "+sObject);
return sObject;
else
return null;
** Setter and getter methods - gets enum of all stored state objects
public Enumeration getAttributeNames() {
return session.getAttributeNames();
public void invalidate() {
session.invalidate();
// Remove all object that is bound to this session
//wip : Resetting instance variable.
//This is necesary as further operations on session will
//result in illegalstateexception
session = null;
public boolean isNew() {
return session.isNew();
public void setMaxInactiveInterval(int interval) {
session.setMaxInactiveInterval(interval);
* This method returns the host url in the form "www.carclub.com".
* <p>
* The return value is compatible with default_website field of clubs DB table.
* </p>
* @return host url present as part of the http request object
public String getHostURL()
if (request == null)
return null;//No request object present, hence return null
String str = request.getServerName();
//Log.debug("--- The request URL is --- " + str);
return str;
* Flushes <code>out</code> stream.
public void flush()
throws IOException
if (pctx != null)
pctx.getOut().flush();
}
Maybe you are looking for
-
Deletion of master data for 0CS_ORDER
Hello Friends, I have a requirement to enhance an IOBJ 0CS_ORDER with Order status values(2 new statues are added). I have done the enhancement part to the extractor in the source system side. Now after replication in BW, to add 2 new IOBJs in CS_ORD
-
My sound does not work on my Windows 8.1
it stoppped working after i updated it and i went into computer manage ment and went to services and clicked windows audio. i hit start and it said Error 0x800706cc: the endpoint is a duplicate. PLEASE HELP!!
-
How to restrict multiple ess session and access?
Hi experts, how to restrict multiple session for ess user? and multi access for same ess user? our problem is when user login to ess (doing session, for example leave request) and at the same time their manager is accessing travel approval task for t
-
ISE 1.2 & AD & Meraki - Per User Group Policy ?
I am working on a PoC for a deployment in an MDU. We are using Meraki switches and access points. There are 250 units in the building, each unit will have it's own subnet. The goal is to have the tenant be able to connect to a common building SSID an
-
This happened all of a sudden today and I didn't change anything.