RE: Generating a random alphanumeric string

2001-03-01 Thread Adrian Papari

i did this a few weeks ago; the code is far from "clean'n'nice", but it does
what it's supposed to, here goes:


Random pwdGen = new Random( System.currentTimeMillis() );
Character temp = new Character( 'a' );
StringBuffer pwd = new StringBuffer();
Vector charPwd = new Vector();
int i = 0;

//0-9
for ( i = 48; 57 >= i; i++ )
{
temp = new Character( ( char ) i );
charPwd.addElement( temp );
}

//a-z A-Z
for ( i = 65; 90 >= i; i++ )
{
temp = new Character( ( char ) i );
charPwd.addElement( temp );
}
for ( i = 97; 122 >= i; i++ )
{
temp = new Character( ( char ) i );
charPwd.addElement( temp );
}

//where i == length of alphanumeric string.
for ( i = 0; 10 > i; i++ )
{
pwd.append(  ( Character ) charPwd.elementAt( ( int ) ( charPwd.size() *
pwdGen.nextFloat() ) ) );
}


 
//adrian.

-Original Message-
From: Cato, Christopher [mailto:[EMAIL PROTECTED]]
Sent: 01 March 2001 15:05
To: '[EMAIL PROTECTED]'
Subject: Generating a random alphanumeric string


Hello, can anyone show me an example or give me a clue about how
to generate a random alphanumeric string of lets say 16-32 chars?
TomCat is obviously doing it for the session ids, but how would I
do the same in a servlet?

Regards,

Christopher Cato

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




RE: Logging problems

2001-02-02 Thread Adrian Papari

well; you could always write your own logging-routine/class... and then in
your code handle exceptions similar to the example-"code" below:

try
{
/* lot of important code */
}
catch ( ExceptionYouWantToCatch excp )
{
new LogFile( excp.getMessage(), logFilePath );
}

there's also been a lot of talk on how to do the logging in tomcat... as far
as i know, no one has successfully logged everything they intended to log
(by configuring the supposed files) or perhaps it's just me ;)

Best Regards & Good Luck,
//Adrian Papari.

-Original Message-
From: Nik Makepeace [mailto:[EMAIL PROTECTED]]
Sent: 02 February 2001 16:56
To: [EMAIL PROTECTED]
Subject: RE: Logging problems


On 2 Feb 2001, at 16:09, Adrian Papari wrote:

> how do you handle the exceptions? if you, for instance, redirect the
> user to an error page when an error occurs, you (or, erm, the user )
> shouldn't see the internal error messages.

They aren't 500 errors, but rather conscious decisions to write to
System.err in the source for the servlets.  Basically, we are using
System.err to write debug for our servlets.

Jserv used to pick up System.err and send it to its error log, but it
seems like Tomcat doesn't behave this way.  Any clues?  We are really
stumped.

Nik

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




RE: Logging problems

2001-02-02 Thread Adrian Papari

how do you handle the exceptions? if you, for instance, redirect the user to
an error page when an error occurs, you (or, erm, the user ) shouldn't see
the internal error messages.

Good luck,
//adrian papari

-Original Message-
From: Nik Makepeace [mailto:[EMAIL PROTECTED]]
Sent: 02 February 2001 16:01
To: [EMAIL PROTECTED]
Subject: Logging problems


Does anyone know how to stop tomcat sending all the servlet error
output to the screen?  The Loggers adequatelt trap and write all the
tomcat output, but System.err always seems to go to screen.
Any suggestions?

Nik

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




RE: Tools.jar

2001-01-24 Thread Adrian Papari

Hi,

 In the Tomcat manual it says that it's possible to log different servlet or
projects. How would such a configuration look? Generally;  I'd like to log
all the output from System.out.println() to a logfile, as well as showing it
in the console. It's intended to be used at the beta stages of every
project, makes debugging a whole lot easier - currently i just spit out a
lot of information to the console.
 Any ideas on such a configuration would look?

Best Regards,
//Adrian Papari


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]