Unordered HashTable
I need help with my HashTable as well..this is an unordered HashTable.
I want to change my Add method so that it takes an Object o rather than and int and a String. the problem is I'm having a problem figuring out how to do just that. my Add Method header is
void Add(int key,String name)
but I want it to be boolean Add(Object o)
but I want to call my add method like:
where x is the instance of HashTable (this is in the main method)
x.Add(5,"Hank Hill");
the other thing in my Add Method that I'm failing at grasping is creating a Data D that contains both the key and the name such that there's a D.key to compare keys with. I looked at the pseudo on wikipedia and realized after a great deal that there way is about 1000x better than mine so I'm going to try and adopt their method.
this is my current Add method and I don't like it:
void Add(int key,String name)//headache^2 but I think it works.
int position=0;
int alpha = key%this.size;
if (array[alpha] == null) { array[alpha] = key+"\t"+name; }
//if not empty then add quotient to key%size 55%11 = 0..quotient =5, so increment by 5%11 until null spot is found probe seq =0%11,5%11,10%11,15%11
else
for (int i=0;i<this.size;i++)
position = alpha + ((key/this.size)%this.size);
if (array[position] == null) { array[position] = key+"\t"+name; break; }
}Thanks in advance to anyone wiling to take the time and help me out.
Message was edited by:
pubert>
You should follow Java naming conventions. Method names start with a lower-case letter.
Anyway...so this is a homework assignment where you're implementing a hash table, correct? And you have apparently implemented an add method that takes a hashcode, and a String, which apparently is the value you're storing. Correct?
Why are you storing the hashtable value in the array?
What do you mean by "Data D"? Is that some class that your teacher told you about? You do realize that these forums are international and have nothing to do with your school, right?
Anyway, you now want to make your hashtable take an Object, and not a specific String and not require the hashcode. Right?
So take the hashcode from the Object argument via the hashCode method (all Objects have that), and just store the Object in the array, don't store some weird combo of the hashcode and a String.
Does that help?
Similar Messages
-
In my original email I should have made the point clear that an indexed
column was required, that led to some confusion, apologies.
Under Oracle 7 even if the column is indexed the query engine still does a
full scan of the index to find the maximum or minimum value. As strange as
this seems it is possible to view it using the Oracle trace functions such
as tkprof. This method is quicker than not having an index but the cursor
method is far more efficient.
When using a cursor based approach Oracle will go straight to the first
record of the index (depending on MAX or MIN) and retrieve the data. By
exiting at that point the function has been performed and the I/O operations
are extremely low compared to a full index scan.
Of course there is a trade off depending on the amount of rows but for large
indexed tables the cursor approach will be far faster than the normal
functions. I'm not sure how other RDBMS's handle MAX/MIN but this has been
my experience with Oracle. This process may be faster still by using PL/SQL
but then you are incorporating specific database languages which is
obviously a problem if you port to a different RDBMS. Here is some code you
can try for Oracle PL/SQL functions:
declare
cursor myCur1 is
select number_field
from number_table
order by number_field desc;
begin
open myCur1;
fetch myCur1 into :max_val;
close myCur1;
end;
I hope this clarifies things a bit more. If in doubt of the execution plan
of a performance critical query use the database trace functions as they
show up all sorts of surprises. MAX and MIN are easy to understand when
viewing code but perform poorly under Oracle, whether v8 behaves differently
I have yet to discover.
Cheers,
Dylan.
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Thursday, 7 January 1999 3:37
To: [email protected]
Subject: RE: SQL functions in TOOL code
I guess my point is that MAX can always be implemented more
efficiently than the SORT/ORDER-BY approach (but may not be the
case, depending on the RDBMS). If an ORDER-BY
can use an index (which means that the indexing mechanism involves
a sorted collection rather than an unordered hashtable) so can
MAX - in which case finding a MAX value could be implemented
in either O(1) or O(logn) time, depending on the implementation.
The last sentence being the major point of this whole discussion,
which is that your mileage may vary depending on the RDBMS - so
try using both approaches if performance is a problem.
In terms of maintenance, MAX is the much more intuitive approach
(In My Opinion, of course), since a programmer can tell right away
what the code is attempting to do.
Chad Stansbury
BORN Information Services, Inc.
-----Original Message-----
From: [email protected]
To: [email protected]; [email protected]; [email protected]
Sent: 1/6/99 10:45 AM
Subject: RE: SQL functions in TOOL code
Well, yes, but in that specific case (looking for max() value) would not
be
true that, if you have an index (and only then) on that specific column
some
databases (like Oracle) will be smart enough to use index and find max
value
without full table scan and without using order by clause?
Dariusz Rakowicz
Consultant
BORN Information Services (http://www.born.com)
8101 E. Prentice Ave, Suite 310
Englewood, CO 80111
303-846-8273
[email protected]
-----Original Message-----
From: Sycamore [SMTP:[email protected]]
Sent: Wednesday, January 06, 1999 10:29 AM
To: [email protected]; [email protected]
Subject: Re: SQL functions in TOOL code
If (and only if) an index exists on the exact columns in the ORDER BY
clause, some databases are smart enough to traverse the index (inforward
or
reverse order) instead of doing a table scan followed by a sort.
If there is no appropriate index, you always end up with some kind ofsort
step.
Of course this is all highly schema- and database-dependent, so youmust
weigh those factors when deciding to exploit this behavior.
Kevin Klein
Sycamore Group, LLC
Milwaukee
-----Original Message-----
From: [email protected] <[email protected]>
To: [email protected] <[email protected]>
Date: Wednesday, January 06, 1999 9:40 AM
Subject: RE: SQL functions in TOOL code
This seems a bit counter-intuitive to me... primarily due to
the fact that both MAX and ORDER-BY functionality would require
a full table scan on the given column... no? However, I would
think that a MAX can be implemented more efficiently since it
just requires the max value in a given set (which can be performed
in O(n) time on an unordered set) versus an ORDER-BY (sort)
performance on an unordered set of at best O(nlogn) time.
Am I missing something? Please set me straight on this 'un.
Chad Stansbury
BORN Information Services, Inc.
-----Original Message-----
From: Jones, Dylan
To: 'Vuong, Van'
Cc: [email protected]
Sent: 1/5/99 4:42 PM
Subject: RE: SQL functions in TOOL code
Hi Van,
Operating a function such as MAX or MIN is possible as given in your
example
but it is worth pointing out the performance overhead with such a
method.
When you use MAX, Oracle will do a full table scan of the column so
if
you
have a great many rows it is very inefficient.
In this case use a cursor based approach and depending on your
requirments
(MAX/MIN) use a descending or ascending ORDER BY clause.
eg.
begin transaction
for ( aDate : SomeDateDomain ) in
sql select DATE_FIELD
from DATE_TABLE
order by
DATE_FIELD DESC
on session MySessionSO
do
found = TRUE;
aLatestDate.SetValue(aDate);
// Only bother about the first record
exit;
end for;
end transaction;
On very large tables the performance increases with the above method
will be
considerable so it is worth considering which method to use whensizing
your
database and writing your code.
Cheers,
Dylan.
-----Original Message-----
From: Vuong, Van [mailto:[email protected]]
Sent: Tuesday, 5 January 1999 6:50
To: [email protected]
Subject: SQL functions in TOOL code
Is it possible to execute a SQL function from TOOL code?
For example:
SQL SELECT Max(Version) INTO :MyVersion
FROM Template_Design
WHERE Template_Name = :TemplateName
ON SESSION MySession;
The function in this example is MAX().
I am connected to an Oracle database.
Thanks,
Van Vuong
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive<URL:http://pinehurst.sageit.com/listarchive/>
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive<URL:http://pinehurst.sageit.com/listarchive/>
>
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive<URL:http://pinehurst.sageit.com/listarchive/>
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/> -
folks i have hashtable as
Hashtable <Integer,String>arr = new Hashtable<Integer,String>();
arr.put(11,"Hello World");
arr.put(12,"Kamran1");
arr.put(13,"Kamran2");
arr.put(14,"Kamran3");
arr.put(15,"Kamran5");
arr.put(16,"Kamran6");
arr.put(17,"Kamran7");
now i want to get all the elements of the hashtable after key == 14 so if
int mk = 14;
// I want that i should get all the values after 14 .. Is it possible
// I ain't talking about using Enumeration because that iterates through the whole hashtable and i dont want it.. i want iteration after one particular key only ?Hashtable and HashMap are unordered Maps.
If youwant an ordered Map I suggest TreeMap which is NavigableMap
[http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html]
The method you can use is tailMap(14) which wil give you a sub map which contains all the entires 14 and after in increasing order. -
How can i get the all values from the Property file to Hashtable?
how can i get the all values from the Property file to Hashtable?
ok,consider my property file name is pro.PROPERTIES
and it contain
8326=sun developer
4306=sun java developer
3943=java developer
how can i get the all keys & values from the pro.PROPERTIES to hashtable
plz help guys..............The Properties class is already a subclass of Hashtable. So if you have a Properties object, you already have a Hashtable. So all you need to do is the first part of that:Properties props = new Properties();
InputStream is = new FileInputStream("tivoli.properties");
props.load(is); -
Unable to reference items in a hashtable
HI,
I'm having a bad PowerShell day today!
My sample script to read in a text file and put the data into a hash table works just fine:
$InputFile=Get-Content C:\Out\ktf06011.REQ
$CurrentUserHashTable = @{}
ForEach ($Line in $InputFile)
$Data=$Line.Split("=")
$Label=$Data[0].Trim()
$Label=$Label.Insert(($Label.Length),"`"")
$Label=$Label.Insert(0,"`"")
$Value=$Data[1].Trim()
$Value=$Value.Insert(($Value.Length),"`"")
$Value=$Value.Insert(0,"`"")
$CurrentUserHashTable.Add($Label,$Value)
$CurrentUserHashTable
However, when I use this within a script that uses a file system watcher event to discover the presence of the text file, I cannot get anything from the hash table. I can see my variables being created, ready to pass on to the .add statement. I have found
a workaround for now - not using a hash table - but would love to know why I see this behaviour and suggestions for getting at the data.
Here is the code that I'm having trouble with.
$folder = 'c:\In'
$OutFolder = 'c:\Out'
$filter = '*.*'
$CurrentUserHashTable = $NULL
$FileSystemWatcher = New-Object IO.FileSystemWatcher $folder, $filter -Property @{IncludeSubdirectories = $false;NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'}
Register-ObjectEvent $FileSystemWatcher Created -SourceIdentifier FileCreated -Action {
$name = $Event.SourceEventArgs.Name
$InputFile=Get-Content $folder\$name
ForEach ($Line in $InputFile)
#Write-Host $Line
$CurrentUserHashTable = @{}
$Data=$Line.Split("=")
#Write-Host "Data: " $Data
$Label=$Data[0].Trim()
$Label=$Label.Insert(($Label.Length),"`"")
$Label=$Label.Insert(0,"`"")
#Write-Host "Label: " $Label
$Value=$Data[1].Trim()
$Value=$Value.Insert(($Value.Length),"`"")
$Value=$Value.Insert(0,"`"")
#Write-Host "Value: " $Value
$CurrentUserHashTable.Add($Label,$Value)
$CurrentUserHashTable
Move-Item $folder\$name $OutFolder -Force
#Label: "ID"
#Value: "abc00001"
#Label: "PID"
#Value: "00001"
#Label: "Title"
#Value: "Mr"
#Label: "Initials"
#Value: "XY"
#Label: "Forename"
#Value: "Mickey"
#Label: "Surname"
#Value: "Mouse"
#Label: "Siteabbrev"
#Value: "UK"
#Label: "Status"
#Value: "STAFF"
#Label: "BUabbrev"
#Value: "NOBU"
#Label: "Department"
#Value: "Finance"
Note the commented bits at the bottom are the output of
Write-Host "Value: " $Value
and
Write-Host "Label: " $Label
Also, if the following are placed within the loop, I see all data items being returned, so I know that they are added to the hash table. If they are added outside the loop, I just get the final entry "Department"
Write-Host "Keys:" $CurrentUserHashTable.Keys
Write-Host "Values:" $CurrentUserHashTable.Values
Many thanks,
JonRhys,
Thanks that was so obvious, I couldn't see it!
I knew the answer would be simple.
Made the amendment to my script and can now get at the data in the hashtable, via (e.g.)
$Department=$CurrentUserHashTable.'"Department"'
Thanks again.
Jon -
Difference Between HashMap and HashTable
Difference Between HashMap and HashTable
Please explain with an exampleI have a situation in Java Collection and i am not
able to figure a good solution. I am scared about the
performance and memory that wil be used
I have 5 List objects with thousands and thousands of
records in it. The List is populated by a database
query using jdbcTemplate which return like 200,000
records
Each record is identified by POLICY_ID. They may be
List with multiple records for a POLICY_ID
I want to extract each POLICY_ID from all the 5 List
and make a single List object for each POLICY_ID and
for each List and pass it to a print job which will
print the data for a POLICY_ID
Example
Let say we have POLICY_ID = 15432
List1 has one record for 15432
List2 has one record for 15432
List3 has one record for 15432
List4 has three record for 15432
List5 has three record for 15432
From the 200,000 records in List1 i want to generate
a seperate list with 1 record for policy id 15432 and
let name is Listperpolicy
after this logic we have
Listperpolicy1
Listperpolicy2
Listperpolicy3
Listperpolicy4
Listperpolicy5
call print job ( Listperpolicy1, Listperpolicy2,
Listperpolicy3, Listperpolicy4, Listperpolicy5)
Please let me know
Thanks a Lotttttttttdon't worry about performance until you've got a working application. second-guessing what the performance bottlenecks will be is futile -
How can I get the total "values" in a hashtable ?
i know that i can get the total values in a hashtable by hash.elements() method. It returns an
enumeration with all the values present in this hashtable. this is fine upto here.
Now the preoblem is:
According to what rule this enumeration will be returned. I mean..
If i added in key A with value a,
then key B with value b;
then key C with value c;
then key D with value d;
(They all are objects of type String)
now i call ... hash.elements(); Suppose it returns Enumeration enum;.
Now in what order they all are present in this hashtable.
Meaning is that if i move arond this enum in what sequence they all will be returned.
option A ) In the same order as they were inserted in hashtable.
option B ) According to LIFO;
option C) There is no fix rules , simply it return all the elements and u cannot judge that the first element in enum was really the first element inserted in the hashtable and the second element of enum was really the second element inserted in the hashtable.
What do u think..which option is correct ?
Ny idea will highly appreciated.
Thanks in advance.
Sanjeev Dhimanhi, i am again..
boss ! this is not true..u just change the order and or change the keys and something like ...
"Sanjeev", "hello"
"Dhiman", "hi"
"Technosys" ,"Services"
u will find that its not LIFO..really i was thinking before coding my project that option A is correct and with knowledge i wrote 3 - 4 classes but when i run the programm its starts throwing errors.
so, i posted this question. I think "apppu" is right.
I think , firstly hash is calculated for each value and that value is returned which can be received in a fastest way and hence not necessarily in LIFO and FIFO..
Thanks to u also as u gave ur precious time for me.
Once again.
Thank you very much.
Sanjeev Dhiman -
Problem in Jtree while retrieving values from a hashtable
Hi
I am trying to show some values in a Jtree.I am receiving the values in a hashtable.The hashtable contains unique key but duplicate values.i want to show that values of that hashtable in a tree(but unique values)and under each value show all the key of it.can you please tell me how to do that.
thanksIf i understand right, you want to do something like this:
Hashtable values = yourhashtable;
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Values");
HashMap<Object, DefaultMutableTreeNode> nodes = new HashMap<Object, DefaultMutableTreeNode>();
Iterator ii = values.keySet().iterator();
while (ii.hasNext()) {
Object key = ii.next();
Object value = values.get(key);
if (nodes.containsKey(value)) {
DefaultMutableTreeNode node = nodes.get(value);
DefaultMutableTreeNode child = new DefaultMutableTreeNode(key);
node.add(child);
} else {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(value);
DefaultMutableTreeNode child = new DefaultMutableTreeNode(key);
node.add(child);
nodes.put(value, node);
root.add(node);
JTree tree = new JTree(root);Hope this helps,
Alex. -
Reading Values from a Hashtable.Please guideu
Chaps,
I am in a strange situation
I am having a hashtable with the flwg values
Entertainment Games
Entertainment Video
PIM Calculator
Entertainment Jump
Settings Set
Entertainment Poker
Now,I need to search this hashtable for the
Object 'Entertainment' and whatever is the
value of this,is put in an Array
for this I am using:
String s[];
Enumeration e;
for(int i=0; i<ht.size(); i++){
String s = (String)ht.get("Entertainment");
// I am stuck after this? Can some one please help?
Object value = ht.get("Entertainment");
But if you are doing this (I can't tell if this is what you're doing from your first post, though):
ht.put("Entertainment", onething);
ht.put("Entertainment", anotherthing);
ht.put("Entertainment", athirdthing);
Then there will only be athirdthing in the table, cuz it'll overwrite the previous values. -
Need help in using hashtable as a property of a form bean
Hi,
Is it possible to use a hashtable as a property of the bean.
Well this is the problem i have
I am using a hashtable as property and i want it to store from(/retrive into} form as ints/strings
I have a
JSP Page
SampleAction --Action
SampleForm --ActionForm
Sample(bean)
=============
JSP Page
(within the html:form tag)
<html:text property="sample.number" />
====================
struts-config links to
SampleAction
SampleForm
==============
SampleForm
Sample sample = new Sample();
reset(){ ...impl...}
validate(){.... impl.....}
=================
Sample.java
private Hashtable prop = new Hashtable();
public int getNumber()
return ((Integer)prop.get("number")).intValue();
public void setNumber(int number)
prop.put("number",new Integer(number));
====================================
this setup understandbly gives me a error like this
no getter method for property sample.number
PLEASE DO remember that i have a large number of mixed types in my form that needs to be populated into the bean and i detest using that many variables(in the bean)
I NEED TO A KNOW A SOLN. PLEASE
Thanx in advance
cheers
AshHi,
I think the solution for your problem is
put a form tag in your jsp page.
name it as your form name defined in the struts-config.xml.
in your case
it is 'sample'.
And make changes in the html:text tag like,
<html:text name="sample" property="number" />
Hope it will work.. have fun !!! -
How to put data into a hashtable from a text file
I need some help to put the words in a text file to a hashtable.The text file
consist of words and the following set of punctuation marks {, . ; : } and spaces.
thanks in advance.Navy_Coder wrote:
6 zebras.But you must marry his eldest daughter as well, for that dowry. -
hello,
I've developed a program which is prefectly working on java 1.5.0 version.
but when run on java1.4.0. it gives run time error in this code.
first i'm getting error in second hashtable. put function where i'm using key as an integer.this is running on 1.5 version but have to change key as string on 1.4. but after that it is still not working properly.
I want that when i clicked on open then it must show both file
1. that have hdr extension
2. that have same name as the corrseponding .hdr file but without extension.
this program show desired result on 1.5 but on 1.4 it display only .hdr file.
pls. help me regarding this .
// class hdr file filter
import java.io.File;
import java.util.Hashtable;
import java.util.Enumeration;
import javax.swing.*;
import javax.swing.filechooser.*;
public class hdrFileFilter extends FileFilter {
private Hashtable filters = null;
private Hashtable noextensionfilter = null;
private String noextensionname=null;
private String extensionname = null;
private String description = null;
private String fullDescription = null;
private boolean useExtensionsInDescription = true;
private String fname = null;
public File noextensionarray[];
int count=0;
int counthdr=0;
int i=0;
//all files are accepted.
public hdrFileFilter()
this.filters = new Hashtable();
//Creates a file filter that accepts files with the given extension.
public hdrFileFilter(String extension)
this(extension,null);
//Creates a file filter that accepts the given file type.
public hdrFileFilter(String extension, String description)
this();
if(extension!=null)
addExtension(extension);
if(description!=null) setDescription(description);
//Return true if this file should be shown in the directory pane,false if it shouldn't.
public boolean accept(File f) {
if(f != null) {
if(f.isDirectory()) {
return true;
String extension = getExtension(f);
if(extension != null && filters.get(getExtension(f)) != null)
fname=f.getName();
extensionname=fname.substring(0,fname.lastIndexOf('.'));
counthdr+=1;
return true;
if(extension == null)
noextensionfilter=new Hashtable(20);
noextensionname=f.getName();
noextensionfilter.put(count,noextensionname);
count=count + 1;
if(noextensionfilter.get(count) == extensionname)
noextensionarray=new File[20];
noextensionarray=f
System.out.println("file:" +noextensionarray[i]);
i++;
return true;
return false;
//Return the extension portion of the file's name .
public String getExtension(File f)
if(f != null)
String filename = f.getName();
int i = filename.lastIndexOf('.');
if(i>0 && i<filename.length()-1)
return filename.substring(i+1).toLowerCase();
return null;
//Adds a filetype "dot" extension to filter against.
public void addExtension(String extension)
if(filters == null)
filters = new Hashtable(20);
filters.put(extension.toLowerCase(), this);
fullDescription = null;
public String getDescription()
if(fullDescription == null)
if(description == null || isExtensionListInDescription())
fullDescription = description==null ? "(" : description + " (";
// build the description from the extension list
Enumeration extensions = filters.keys();
if(extensions != null)
Object nn=extensions.nextElement();
fullDescription += "." + nn;
while (extensions.hasMoreElements())
fullDescription += ", ." + nn;
fullDescription += ")";
else
fullDescription = description;
return fullDescription;
public void setDescription(String description)
this.description = description;
fullDescription = null;
public void setExtensionListInDescription(boolean b) {
useExtensionsInDescription = b;
fullDescription = null;
public boolean isExtensionListInDescription()
return useExtensionsInDescription;Might be fixable if you do something like
javac -target 1.4
Bytecodes are different in 1.5 and thus not backward compatible -
How can I use active user session that's in an application scope Hashtable?
First of all, is it possible to use the same session after a user exits and then returns?
Second, if it is possible, then please tell me what I need to do. So far, this is what I have been doing...
1.) The user submits login credentials
2.) The user is authenticated.
3.) The user does not have an existing session, so a new one is created.
4.) The user closes the browser.
5.) The user returns to login page and submits login credentials.
6.) The user is authenticated.
7.) The user has an existing session, so it should be used.
This is where I'm having trouble. All active sessions for my application are stored in a Hashtable. I have been using <%@ page session="false" %> so that a new session is not automatically created. Each time before I create a new session, I check my Hashtable to see if that user has an existing session. If a session exists for that user, then I would like to continue using that session if possible. I have used the methods request.getSession() and request.getSession(false), but a new session is always returned.
I could create a new session, copy the attributes from the old session(which is stored in my Hashtable) to the new session, and then invalidate the old session, but I'd rather not do that.
Is there a way that I can use existing sessions that I have stored in my Hashtable?First of all, is it possible to use the same session after a user exits and then returns?No, I don't think so. Let me explain why. When the server creates a session object for each client, it needs to know which client is making the request. Remember that HTTP is a stateless protocol. Every time a client makes a request, it sends some sort of session id to the server to let the server know who is trying to make the request. The server will then check to see if a session object exists for that particular client and if so, it will make sure that the max inactive interval (maximum time alloted for that client's session) has not been exceeded. If every thing is okay, then the client can access the session object to get values that were previously placed there. There are many ways that servers try to keep track of clients. One way is to have the clients write the session ID using cookies. But, many people like disallow cookies. So some servers do what is known as URL rewriting. That is, they will write the session ID on the end of the query string. This can also be accomplished programmatically, but it can be taxing to do. Anways, the point is that the client and the server have to have some sort of link between each other and that link is the session ID. So, if the browser is closed, the session ID is lost. That particular client will be forced to get a new session ID the next time the following code is executed:
//create a session object and set its values
HttpSession session = request.getSession(true);>
Second, if it is possible, then please tell me what I
need to do. So far, this is what I have been doing...
1.) The user submits login credentials
2.) The user is authenticated.
3.) The user does not have an existing session, so a
new one is created.
4.) The user closes the browser.
5.) The user returns to login page and submits login
credentials.
6.) The user is authenticated.
7.) The user has an existing session, so it should
be used.If you really want to do something like this, you could make up your own ID and store it as a cookie on the client. I've never tried anything like this before so you would have to do your own research. Are you sure you want to do something like this. There is a reason why it works the way it does. There is also a reason why you want to keep the session timeout value some what small. Let me give you an example of some craziness with sessions. A client we once had wanted to keep their sessions open for 4 hours because they said there clients simply did not like to log in all the time. I nearly gasped when I was told we needed to do this. When you make the session time out large (i.e. the maxInactiveInterval( )), then session objects stick around longer in the server. Let's say a client logs into the server and receives a session object. Then, the client makes a few requests. The server knows to keep the session alive as long as the time between requests has not exceeded 4 hours. Then the client closes the browser. How is the server suppose to know that the browser was closed. Well, it doesn't. It just knows to check times between requests. So, that particular session object won't be garbage collected until the session times out. What if a whole bunch of clients did this. Yucko. The server would have a whole bunch of session objects living in memory. What a waste. This is all above and beyond the typical security problems that can arise from having a session open for so long. To make a long story short, you really shouldn't do what you are trying to do unless it is the nature of the app.
>
This is where I'm having trouble. All active sessions
for my application are stored in a Hashtable. I have
been using <%@ page session="false" %> so that a new
session is not automatically created. Each time
before I create a new session, I check my Hashtable
to see if that user has an existing session. If a
session exists for that user, then I would like to
continue using that session if possible. I have used
the methods request.getSession() and
request.getSession(false), but a new session is
always returned.
I could create a new session, copy the attributes from
the old session(which is stored in my Hashtable) to
the new session, and then invalidate the old session,
but I'd rather not do that.
Is there a way that I can use existing sessions that I
have stored in my Hashtable? -
How to get unordered/ordered list in ADF JSF
Hey,
So I'm thinking this is a pretty simple task but I just can't get it to work or find anything on it. I just want a simple unordered or ordered list in my JSF view, the text of each list element being an <af:outputText> value. At the moment I have something like:
<ol>
<li>
<af:outputText value="something" />
</li>
<li>
<af:outputText value="something2" />
<af:goLink text=" text " id="gl1" destination="/faces/mypage.jsp"/>
<af:outputText value="something3" />
</li>
<ol>So I expect it to output the below, but instead its completely messed up.
1. something
2. something2 text something3
It's getting messed up because ADF is adding divs around the <af:outputText> tags, as well as completing the li tags before my ones. Surely there is a way to do this either through the framework or other means? Anyone know?
Edited by: Ross on 30-Nov-2011 22:08An option is to wrap your elements in an af:panelList with listStyle='list-style-type:decimal', such that the af:panelList does the numbering of the elements for you. More information on the af:panelList can be found here: http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_panelList.html
For the second list item made up of your 3 components, try wrapping them in a horizintal af:panelGroupLayout.
eg:
<af:panelList id="pl1" listStyle='list-style-type:decimal'>
<af:outputText value="something" />
<af:panelGroupLayout layout="horizontal">
<af:outputText value="something2" />
<af:goLink text=" text " id="gl1" destination="/faces/mypage.jsp"/>
<af:outputText value="something3" />
</af:panelGroupLayout>
</af:panelList>CM. -
Unordered list not showing up as indented bullet points within Accordian
http://www.foundationforyoutharts.org/test/Programs.html
I have a page using the spry accordian, and about five different catagories of information. Some of the copy is in unordered lists (in martial arts catagories), but it shows up as as regular text. Any ideas on how to make it view as a typical unordered list with bullet points and indented?
Thanks for taking time to look at this.Add a margin-left of 20px to your ul.
Either added it in your stylesheet. or directly on the element:
<ul style="margin-left:20px">
Maybe you are looking for
-
How can I remove the service reply from my 2700?
Hi, Can anyone help me to remove the service reply which makes an irritating sound everytime I send an email? Thanks, Vicky
-
Where can I buy a charger for an ipod mini 1st generation
Where can I buy a charger for an ipod mini 1st generation
-
I'm researching a little into wireless troubleshooting and I'm starting to get a little confused about the differences between several modes available on Cisco access points. The ones I'm looking at are: - monitor mode - sniffer mode - scanner mode I
-
hi all need help to solve this problem In a file called AllBalancedOfSize.java write a method with the signature: public void printBalanced(int len) that uses recursion (either directly or indirectly) and prints all balanced strings, composed solely
-
I had siri called me master and then forgot about it. today i emailed a teacher. will they be able to see my nickname?