Vector + session varaible
Hi ,
Would I be able to set a vactor variable to a session varaible in jsp? If so how can it be done?
Thanks
vivek
2 choises....
either you have function from bi to have results from the fact table for 5 year ago/
or find the desired sql query from your client sql tool (using dual) and pass it in the administrator
hope i helped....
http://greekoraclebi.blogspot.com/
///////////////////////////////////////
Similar Messages
-
I want to store a Vector variable into a session and use it
next time,but my code does not work.
Vector vect1;
//set vector into session
vect1 = (Vector)request.getAttribute("carrierCode");
session.putValue("carrierCode",vect1);
//Retrieve from session
vect1=(Vector)session.getvalue("carrierCode");
Your help is highly appreciated,Thanks in advaceI want to store a Vector variable into a session and
use it
next time,but my code does not work.
Vector vect1;
//set vector into session
vect1 = (Vector)request.getAttribute("carrierCode");
session.putValue("carrierCode",vect1);
//Retrieve from session
vect1=(Vector)session.getvalue("carrierCode");What do you mean by "but my code does not work"? What is the error / exception you are getting?
Try this code,
Vector vect1;
//set vector into session
vect1 = (Vector)request.getAttribute("carrierCode");
if(vect1 == null || vect1.size() ==0)
vect1 = new Vector();
session.putValue("carrierCode",vect1);
//Retrieve from session
vect1=(Vector)session.getvalue("carrierCode"); -
Session varaible in region heading or title
I have a query result in a report page - it is details for a customer - and i want that customer name in the region heading ...
I have a session variable called P300_CONTACT_NAME with the name, and I want to display that in my region heading or title. I don't want to make this variable an application level variable - it needs to be session based only.
any help is appreciated....William,
Use: &P300_CONTACT_NAME.
Note that the item name is in upper case and is followed by a . (dot).
Sergio -
Session varaible data lost!
Hi,
I have a situation where I have A servlet set with some session variables from here another page url is called which is resides in a different machine and server. Again when A servlet is called through a url from the 2nd machine , the original session data set in A servlet is lost?
Any idea how the session data in A servlet could be retained?From all that I could understand from your questions, there are two servlets running in two different machines. They can never obtain each others session data.
-
Hi
I am passing vector in session between two jsp's
In the first jsp I have
session.setAttribute("serialnumber_Vect",serialno_Vect);
In the recieving jsp I have the following
Vector serial_Vect = (Vector)session.getAttribute("serialnumber_Vect");
But i am not able to see the values in the receiving jsp
what is the problem
Thanks
Arndid u set your scope to session?
-
Saving Vector in session problem
Hi,
Im trying in my servlet to save vector into session and then retrive it:
// new vector
Vector VTree = new Vector();
// session
session = request.getSession(true);
//here I add some elements into vector VTree
VTree.size() // now using method size() I get number>0, so vector is not empty
// saving vector into session attribute SessionTree
session.setAttribute("SessionTree",VTree);
// then I clear vector VTree
VTree.clear();
// and Im trying to get vector from session, still in the same servlet, same method (doGet)
VTree = (Vector)session.getAttribute("SessionTree");
// and result, VTree.size() returns 0...
VTree.size()
Please help me, Im not possible to find error or bad expression...
Thanks, JanThere are no errors. That is how Java works.
//here I add some elements into vector VTree
VTree.size() // now using method size() I get
number>0, so vector is not empty
// saving vector into session attribute SessionTree
session.setAttribute("SessionTree",VTree);You save a reference to that Vector in the session. So both your class and the session have a reference to the same Vector.
// then I clear vector VTree
VTree.clear();So you clear the Vector object. It has no elements now. Both your class and the session have a reference to this Vector, which is now empty.
// and Im trying to get vector from session, still in
the same servlet, same method (doGet)
VTree = (Vector)session.getAttribute("SessionTree");Now you get the reference to the (empty) Vector from the session and assign it to a variable in your class. (Your variable already had a reference to that same Vector.)
// and result, VTree.size() returns 0...
VTree.size()Yes, it does. Because you cleared the Vector earlier.
Remember, assigning a variable doesn't make a copy of an object. It just makes a copy of a reference (like a pointer) to the object. -
Please help with retrieving values from object stored in a vector
hi..
i have a class Magazine with 2 varibles name and price like this
class magazine
String name;
int price;
i have created a vector called selectedmag which stores objects of Magazine class... now each object will contain the name and price rite...
i want to print the values stored in vector ie i want to print the vector elements...like
Name: Mag1
Price: 10
which wil be present in object1...
and then
Name: Mag2
Price:15
which wil be present in object2...
and so on...
plz help...
if i give selectedmag.elementAt(position) i am not able to get the above output...plz help me.....
thanks,
Akshathahi,
Yes i have used a for loop to print the values... it goes like this
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
class Magazine
String title;
int price;
public class sessiontrack1 extends HttpServlet
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
res.setContentType("text/html");
PrintWriter out=res.getWriter();
HttpSession session=req.getSession(true);
// This is my vector
Vector myshoppingcart=(Vector)session.getAttribute("ShoppingCart");
if(myshoppingcart==null)
myshoppingcart=new Vector();
Magazine selectedMag=new Magazine();
selectedMag.title=req.getParameter("Title");
selectedMag.price=Integer.parseInt(req.getParameter("Price"));
//Putting Magazine object into the vector myshoppingcart
myshoppingcart.addElement(selectedMag);
session.setAttribute("ShoppingCart",myshoppingcart);
out.println("<html><body>U have selected these magazines");
out.println("<br>");
//Enumeration vEnum=myshoppincart.elements();
//here a am trying to print output the values
for(int i=0;i<myshoppingcart.size();i++)
out.println("Name:" + (Magazine)myshoppingcart.elementAt(i));
out.println("<br>");
out.println("Price:" + (Magazine)myshoppingcart.elementAt(i));
out.println("<br>");
out.println("</body></html>");
this is a servlet program.... plz suggest me how to print the values... in the following format
Name: Book1
price: Rs 10
Name:Book2
price:Rs 15
Akshatha -
Retrieving All Objects From Session
I'm developing a JSP shopping cart application, i have problem with sessions. A user can add a product to their cart, this adds the product name and the product price to the cart using:
<%
session.setAttribute("pname", pname);
session.setAttribute("pprice", pprice);
%>
The problem I have is viewing the cart. The page must display all items the user has added to the cart. I need to retrieve all the objects from the users session.
session.getAttribute("pname") will only return the last object which was added to the session. Is there a method or mechansim to loop through all the objects in a users session?
Any suggestions appreciated.session.getAttribute("pname") will only return the
last object which was added to the session. Is there a
method or mechansim to loop through all the objects in
a users session?You can't use session.setAttribute("pname",pname); repeatedly. Each time it will overwrite contents of existing attribute. Thats the reason why you are always getting last added value.
You can do one thing. Add pname to the Vector or Hashtable, like this,Vector v = (Vector) session.getAttribute("pname"); // Get the existing Vector in the session.
if(v == null) v = new Vector(); //If there is no attribute "pname" in the session, create an object of Vector.
v.add(pname) //add item to the Vector.
session.setAttribute("pname",v); //Now add this vector to the session.Hope this helps.
Sudha -
Javacard and session variables
Hello,
I'm trying to find a reasonable Javacard technique to handle "session variables" that must be kept between successive APDUs, but must be re-initialized on each card reset (and/or each time the application is selected); e.g. currently selected file, currently selected record, current session key, has the user PIN been verified...
Such variables are best held in RAM, since changing permanent (EEPROM or Flash) variables is so slow (and in the long run limiting the operational life of the card).
Examples in the Java Card Kit 2.2.2 (e.g. JavaPurseCrypto.java) manipulate session variables in the following way:
1) The programmers group session variables of basic type (Short, Byte, Boolean) according to type, and map each such variable at an explicit index of a vector (one per basic type used as session variable).
2) At install() time, each such vector, and each vector session variable, is explicitly allocated as a transient object, and this object is stored in a field of the application (in permanent memory), where it remains across resets.
3) Each use of a session variable of basic type is explicitly translated by the programmer into using the appropriately numbered element of the appropriate vector.
4) Vector session variables require no further syntactic juggling, but eat up an object descriptor worth of permanent data memory (EEPROM or Flash), and a function call + object affectation worth of applet-storage memory (EEPROM, Flash or ROM).
The preparatory phase goes:
public class MyApp extends Applet {
// transientShorts array indices
final static byte TN_IX = 0;
final static byte NEW_BALANCE_IX=(byte)TN_IX+1;
final static byte CURRENT_BALANCE_IX=(byte)NEW_BALANCE_IX+1;
final static byte AMOUNT_IX=(byte)CURRENT_BALANCE_IX+1;
final static byte TRANSACTION_TYPE_IX=(byte)AMOUNT_IX+1;
final static byte SELECTED_FILE_IX=(byte)TRANSACTION_TYPE_IX+1;
final static byte NUM_TRANSIENT_SHORTS=(byte)SELECTED_FILE_IX+1;
// transientBools array indices
final static byte TRANSACTION_INITIALIZED=0;
final static byte UPDATE_INITIALIZED=(byte)TRANSACTION_INITIALIZED+1;
final static byte NUM_TRANSIENT_BOOLS=(byte)UPDATE_INITIALIZED+1;
// remanent variables holding reference for transient variables
private short[] transientShorts;
private boolean[] transientBools;
private byte[] CAD_ID_array;
private byte[] byteArray8; // Signature work array
// install method
public static void install( byte[] bArray, short bOffset, byte bLength ) {
//Create transient objects.
transientShorts = JCSystem.makeTransientShortArray( NUM_TRANSIENT_SHORTS,
JCSystem.CLEAR_ON_DESELECT);
transientBools = JCSystem.makeTransientBooleanArray( NUM_TRANSIENT_BOOLS,
JCSystem.CLEAR_ON_DESELECT);
CAD_ID_array = JCSystem.makeTransientByteArray( (short)4,
JCSystem.CLEAR_ON_DESELECT);
byteArray8 = JCSystem.makeTransientByteArray( (short)8,
JCSystem.CLEAR_ON_DESELECT);
(..)and when it's time for usage, things go:
if (transientShorts[SELECTED_FILE_IX] == (short)0)
transientShorts[SELECTED_FILE_IX] == fid;
transientBools[UPDATE_INITIALIZED] =
sig.verify(MAC_buffer, (short)0, (short)10,
byteArray8, START, SIGNATURE_LENGTH);I find this
a) Verbose and complex.
b) Error-prone: there is nothing to prevent the accidental use of transientShorts[UPDATE_INITIALIZED].
c) Wastefull of memory: each use of a basic-type state variable wastes some code; each vector state variable wastes an object-descriptor worth of permanent data memory, and code for its allocation.
d) Slow at runtime: each use of a "session variable", especially of a basic type, goes thru method invocation(s) which end up painfully slow (at least on some cards), to the point that for repeated uses, one often attain a nice speedup by caching a session variable, and/or transientShorts and the like, into local variables.
As an aside, I don't get if the true allocation of RAM occurs at install time (implying non-selected applications eat up RAM), or at application selection (implying hidden extra overhead).
I dream of an equivalent for the C idiom "struct of state variables". Are these issues discussed, in a Sun manual, or elsewhere? Is there a better way?
Other desperate questions: does a C compiler that output Javacard bytecode make sense/exists? Or a usable Javacard bytecode assembler?
Francois GrieuInteresting post.
I don't have a solution to your problem, but caching the session variables arrays in local variable arrays is a good start. This should be only done when the applet is in context, e.g. selected or accessed through the shareable interface. This values should be written back to EEPROM at e.g. deselect or some other important point of time. Do you run into problems if a tear happens? I don't think so since the session variables should be transactional, and a defined point will commit a transaction.
Analyzing the bytecode is a good idea. I know of a view in JCOP Tools (Eclipse plugin) where you can analyze the bytecode and optimize it to your needs. -
How to find a String in a Vector???
Hi!!
Thanks in advance for read this post. I have a little problem... please help me.
I need to find if a String exists or not in a Vector. The vector is a list of results from a database. Here goes my code:
<html>
... html code ...
<%
int IdClass = Integer.parseInt(request.getParameter("IdClass"));
int module = Integer.parseInt(request.getParameter("module");
Connection conn = null;
Statement stat = null;
ResultSet rs = null;
int oError = -1;
String oMessage = null;
List Functions = new Vector();
CallableStatement cs = null;
try{
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DBConnection.GetConnection(DBConnection.DSN);
if (conn != null) {
cs = conn.prepareCall ("begin procedure(?,?,?,?); end;");
cs.setInt(1,IdClass);
cs.registerOutParameter(2,Types.INTEGER);
cs.registerOutParameter(3,Types.VARCHAR);
cs.registerOutParameter(4,OracleTypes.CURSOR);
cs.execute();
rs = (ResultSet)cs.getObject(4);
oError = cs.getInt(2);
oMessage = cs.getString(3);
if (oError == 0) {
while (rs.next()) {
Functions.add(rs.getString(1));
session.setAttribute("sessionFunctions", Functions);
out.println("<script>document.location.href=\"Ok.jsp\";</script>");
else {
String message = null;
message = "Error "+oError+": "+oMessage;
out.println("<script>document.location.href=\"NO.jsp\";</script>");
cs.close();
if (conn != null) {
conn.close();
%>
... html code...
</html>
That code generates a Vector that contains this:
[1, 2, 3, 6, 7, 8, 15, 28, 35, 41, 58, 65, 66, 68, 71, 74]
In the Ok.jsp page, i have a String like this:
String access = "2,7,14,15,28";
First, i need to get the values of the sessionFunctions.
String X = (String)session.getAttribute("sessionFunctions");
I need to know if each number (2,7,14...) exists in the vector. For example, in this case, the follow numbers exists: 2, 7, 15, 28.
So, if the number exists in the Vector, i will generate some HTML code. If not, i will generate a different HTML Code.
if (String exists in Vector = 1) {
out.println("Yes!!!");
else {
out.println("No...");
Can somebody help me? I`ve read a lot of examples, a lot of posts in this forum, i`ve look a lot of files of another project in my company, but i can�t find how to do this...
Thanks in advance.
Rapeteiro.If you are putting a Vector in a session, you should be able to get it back as a Vector. Try this:
// retrieve Functions Vector from session
Vector userProfile = (Vector) session.getAttribute("sessionFunctions");
String access = "2,7,14,15,28";
// prepare a Vector from this string
Vector accessVector = new Vector();
StringTokenizer acsTokenizer = new StringTokenizer(access, ",");
while(acsTokenizer.hasMoreTokens ())
accessVector.addElement (acsTokenizer.nextElement ());
// check for each function in string against userProfile Vector
for(int f=0;f<accessVector.size ();f++)
String function = (String)accessVector.elementAt (f);
if(userProfile.contains (function)
%>User has access to this function<%
else
%>User does not have access to this function<%
Hope this helps!
-Mak -
Hi, i am facing a problem of the Object set into a session not being visible to the others pages. what did i done wrongly?
here is the code:
in login.jsp (currently hardcode cos i haven recieve that part):
<%@page import="fantasy.team.*,java.util.Vector" session="true"%>
<%
Team t = new Team("Kacheek FC");
session.setAttribute("team",t);
if( session.getAttribute("team") ==null){
out.write("how come null");
}else{
out.write("not null");
%>
Select
//End of coding
not null will be printed
Following code belong to selectPlayer.jsp:
if( session.getAttribute("team") == null){
out.write("i am null"); }else{
out.write("i am not null");
i am null is printed
what is wrong with my coding?
thanks.i do a
if(session.isNew())
out.write("New");
and the result is new.
meaning that my session is invalidate.
that explain my value from "gone" rite?
how to solve this?
thanks. -
Hi All,
Can anybody please tell me as how I can pass vectors from a page to another page and how Can I retieve the value from the next page?
Thanks,
AarthyI am using this code in the first page
request.getSession.setAttribute("vec",v2);In the Recipient page
Vector v5=new Vector();
v5=(Vector)request.getSession().getAttribute("vec");I am getting nullPointerException when i try to get
the size of the vector.Can anyone tell as where I am
going wrong?
Thanks,
AarthyHow did u delclare your vector v2
did u say
Vector v2 = new Vector()
session.setAttribute("vec",v2);
if you just have said
Vector v2 ;
session.setAttribute("vec",v2);
and trying to access v2.size() will throw NULL pointer exception
good luck
KM -
Jsp Page session vaiable to java class and vise versa
Hi to all,
I am new to jsp, i have to programs, one jsp page and another java class. in jsp page i get the user data from html form and put the id in session. here i have to call the session vaiable to my java class where it (variable)initialize a file name.
and same i have to call the java class to jsp page which insert statements to sql server,
Please Help Me.//My Java Class file
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.servlet.http.HttpSession;
import java.sql.Statement;
public class StuInfo extends Object {
//main method begins execution of Java application
public static void main (String args[]){
String StuFile = "C://"+iD+".txt"; // Here i have to get the session varaible.(ID)
try {
In my jsp Page i initilized session as
session.setAttribute("ID",StuId);
I am not able to understand where i have to declear the HTTPSession#getAttribute("ID"); -
I'm returning a vector, but I'm having trouble displaying it. The vector will contain a group of users, each containing FirstName, LastName and EmailAddress. I've the servlet working, but the I'm having trouble repeating the vector.
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>User List</title>
</head>
<body>
<h1>User Email List</h1>
<%@ page import="business.*"%>
<%
Vector users = (Vector ) session.getAttribute("users");
if (users==null){
users = new Vector();
users.setFirstName(request.getParamter("firstName"));
users.setLastName(request.getParamter("LastName"));
users.setEmailAddress(request.getParamter("emailAddress"));
session.setAttribute("users", users);
%>
<table cellpadding="5" border=1>
<tr valign="bottom">
<th>First Name</th>
<th>Last Name</th>
<th>Email Address</th>
</tr>
<% java.util.Vector users = (java.util.Vector)session.getAttribute("users");
for (int i =0; i<users.size(); i++){
business.Users users = (business.Users)users.get(i);
%>
<tr valign="top">
<td><p><%= users.getFirstName() %></td>
<td><p><%= users.getLastName() %></td>
<td><p><%= users.getEmailAddress() %></td>
<td><a href="../servlet/user11.ShowUserServlet?emailAddress=<%=users.getEmailAddress()%>">Update</a></td>
<td><a href="../servlet/user11.DeleteUserServlet?emailAddress=<%=users.getEmailAddress()%>">Delete</a></td>
</tr>
<%}%>
</table>
</body>
</html>Bad idea: Vector users = (Vector ) session.getAttribute("users");
if (users==null){
users = new Vector();
users.setFirstName(request.getParamter("firstName"));
users.setLastName(request.getParamter("LastName"));
users.setEmailAddress(request.getParamter("emailAddress"));
users should probably be an instance of some class User ... -
Hi
I would like to execute few expressions built in Expression Builder and therefore i need Session. Does anyone know how to create or initialize session in JavaFX?
I have this code and at the end I need to execute it (run it) using Session:
ExpressionBuilder builder = new ExpressionBuilder();
Expression exp = builder.get(CODE.getAttributeName()).equal(getCode());
if (isPersisted())
exp = exp.and(builder.get(ID.getAttributeName()).notEqual(getId()));
ReportQuery query = new ReportQuery();
query.setReferenceClass(getClass());
query.addAttribute(ID.getAttributeName());
query.setSelectionCriteria(exp);
+Vector vector = (Vector) session.executeQuery(query);+_
I know I can use statement and write SQL select, but using Expression Builder instead would be more suitable for me. Thank you very much for any suggestion.Googling some of your code snippets would seem to indicate that you are (perhaps) using an older version of Oracle's Toplink product (http://docs.oracle.com/cd/B14099_19/web.1012/b15901/sessions007.htm), so I suggest you consult the documentation for that product or whatever product it is that you are using.
Maybe you are looking for
-
Why is it that I can no longer play Real Time with Bill Mayer on my IPad or IPod.
My IPad and IPod Touch software are up to date. This is the first time I have not been able to download; I've been listening to podcasts for several months. Thanks, Juanita
-
USB drive connected to airport i cant see it??
Hello all, i have an airport extreme. network is all setup fine. I have a USB drive connected to the airport setup for timemachine backups. What i would do is turn it on every week for the day and all my mac would backup to it. Last night i turn it o
-
Return Messages for a BAPI run in Background
Hi all, I am running a BAPI( BAPI_SALESORDER_CHANGE ) in Background task, It works fine and updates the Sales order but i dont get any return messages.But based on the return messages i need to show up on the report which orders got updated and which
-
SAP BPC 10 - Error on Refreshing Reports Input Forms
Hi all, We are working on an BPC 10 Consolidation project for the Netweaver Version. We setup the Environment, Dimensions, Models, etc. We created a few reports too using the Excel interface. These were tested and they worked well. However, then one
-
Disable / Turn off Thumbnail / Icon Preview in Finder?
Can't find any new/recent posts to solve this issue. I want to disable/turn-off the little icon preview in finder. I have to access a lot of images on a server at work. Image files(jpeg, eps, tiff, psd, ai, ect) that are typically 50MB and higher. So