pete johnson

Greenhorn
+ Follow
since Mar 24, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by pete johnson

i am using JTDS driver. after looking at the nested exceptions due to deleting master records that have child records, i found that the nested
exceptions actually do have the names of the tables that have child records. i can extract such information. not quite sure it is true of
other JDBC drivers.

thanks for your input!
hello,

i have a master table and there are a few child tables. i need to
delete a record in the master table, but i dont want to delete
dependent child records by cascading. i want the program to catch
JDBC exception and then to display an alert
of asking users to delete child records manually. i dont want "soft delete"
(using a true/false flag).

to better inform users about where child records reside,
i want the table names to be displayed in the alert. is any
general way for extracting child table names from JDBC exceptions?

thanks for your advice and information!

pete
Hi Bear,

Thanks so much for your tip. It works!

Cheers,
Pete
19 years ago
JSP
I am writing a tag that extends SimpleTagSupport. The task of this
tag is to construct the entire request URL. Servlets API has a few related methods
available from a HttpServletRequest object.

How can I can get access to this object from within a SimpleTagSupport object?
from getJspContext()?

Regards,
Pete
19 years ago
JSP
Basically, it is about displaying information in a table.
The table has many columns and users can select, via a browser interface,
any columns to display and specify the order (from left to right)
selected columns to display on the results page.
19 years ago
JSP
Thanks so much for your input. I know I can do achieve the same goal
purely based on servlets which outputs different pieces of info in
various orders.

Do you know of any other solution that is more elegant?

Regards.
19 years ago
JSP
I have a tag inside which a few other tags can be used OR can be used in
any order. An end user decides which tag ('s info) to display or in what
order. For example,

example 1:

<example:A>
<example:b/>
<example:c/>
<example />
</example:A>

example 1:

<example:A>
<example />
<example:b/>
</example:A>

I hope to write a SINGLE JSP page that can display info in the above examples' way.

I am trying to write a custom tag which is used in the following way:

<example:A>
<example:generate/>
</example:A>

The job of the generate tag is dynamically creating a string such as

<example /><example:b/>

and inserting it into the body of tag A and evalute its body.

I have tried both simple tags and classic tags but have failed to
create a solution. I cannot find a way to manipulate the tag body and
evaluate it dynamically.

Am I doing the right thing? Is it possible for me to create a solution based
on the current JSP specification? Any other ways of doing this type of thing?

Really hope to hear from JSP/tag experts on this forum.

Thanks very much in advance!!

Pete.
19 years ago
JSP
hi, i am doing a servlet/jsp application in which
i put an object on ThreadLocal each time a user
requests some from the application. as you know,
servlet/jsp uses single-threaded model. so the thread for a user
is dead after the application renders a page to
the user. how about the object put on ThreadLocal at
the beginning? i think it cannot be garbage-collected
automatically, but i am not sure. just want to hear
from some experts here.

thanks, pete
hi, i am doing a servlet/jsp application in which
i put an object on ThreadLocal each time a user
requests some from the application. as you know,
servlet/jsp uses single-threaded model. so the thread for a user
is dead after the application renders a page to
the user. how about the object put on ThreadLocal at
the beginning? i think it cannot be garbage-collected
automatically, but i am not sure. just want to hear
from some experts here.

thanks, pete
19 years ago
Carol, thanks very much for your input. It really helps.
you are right! I ran 3 rounds of your code and got one
in the 3rd round:

ate: Tue Apr 05 23:24:52 EDT 2005
SSS: 04/05/2005 23:24:52.093
SS: 04/05/2005 23:24:52.93
S: 04/05/2005 23:24:52.93

I think I made a mistake of translating another problem into
this generic one. My orginial problem is: my web app grabs
data from a SQL server and the following is part of the code:

....
dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
Date date = (Date)columnValue;
System.out.println("date:" + date);
if (date != null) {
String d = dateFormat.format(date);
System.out.println("Formated: " + d);
....

The following is one date pulled from the database:

date:2005-04-03 16:05:28.11
Formated: 04/03/2005 16:05:28.110


I thought it was a generic Java problem. Looks like I need to
find out why this happened in my specific environment.
I did another test as follows:

public static void test2() throws Exception {

SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date myDate = sdf1.parse("2005-04-03 16:05:28.11");
SimpleDateFormat sdf2 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
SimpleDateFormat sdf3 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.S");
System.out.println("Date: " + sdf1.format(myDate));
System.out.println("SSS: " + sdf2.format(myDate));
System.out.println("S: " + sdf3.format(myDate));
}

and I still got the corrects:

Date: 2005-04-03 16:05:28.011
SSS: 04/03/2005 16:05:28.011
S: 04/03/2005 16:05:28.11

Thanks very much for your help here!

Regards,
Pete
19 years ago
Carol,

Thanks for your input. How did you get 04/05/2005 14:23:48.009 in the
first place? I wish my program could do the same thing.

If I reverse the order of your following tests,
S: 04/05/2005 14:23:48.9
SS: 04/05/2005 14:23:48.09
SSS: 04/05/2005 14:23:48.009

I will get the followinig, no matter 1 S or 2 Ss or 3 Ss I use:
S: 04/05/2005 14:23:48.900
SS: 04/05/2005 14:23:48.900
SSS: 04/05/2005 14:23:48.900

This clearly shows a problem: the system is not consistent.

Jeff, I very much appreciate your input.

"Milliseconds will always be accurate to three digits.. "

I dont quite get it. 04/05/2005 14:23:48.900 and 04/05/2005 14:23:48.9
should be interpreted differently, right?

Your convertedDate trick probably does not always work. I may well have
a date with a milliseconds being 900. If you remove the last zero, you
get 90 and that is different than it is actual value 900. Doing a trick
to get accurate milliseconds as a date object has when it is printed
directly via System.out.print(new Date()), in my opinion, shows either
the design for SimpleDateFormat misses something or
probably we dont know the right way to do it.

Thanks, Pete
19 years ago
i tried one S, two Ss and three Ss. none of them works.

is this a JRE problem?

thanks, pete
19 years ago
hi, i have a java.util.Date object and i am using SimpleDateFormat
to format it as follows:

Date myDate = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
System.out.println(myDate); (1)
System.out.println(sdf.format(myDate)); (2)

however, if a Date object in line 1 is displayed as 04/05/2005 04:55:23.14,
then the second is displayed as 04/05/2005 04:55:23.140 (an extra zero).

this is a puzzle to me. how can i make the second display the same as the
first one?

thanks, pete
19 years ago
ben,

my object (only a user object with string, date) is serializable.
i still have the same problem. my observation that
the session object (still has the same session id)
is get recreated with tomcat calling the
regestered session listeners and so is the user object.

thanks, pete
19 years ago
ben,

thanks for the info and i implemented as you described.
i am using tomcat 5.5.7 in development mode. i noticed a strange
situation if you modify and recompile a java program with tamcat
being running. tomcat first removes all sessions via calling the session listener,
and then re-create new sessions objects with same session session IDs,
but this time it does not call registered session listeners when it does this.
so, you will see zero users in your user tracking page.

regards,
pete
19 years ago