Jack Mutansan

Greenhorn
+ Follow
since Jul 10, 2017
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jack Mutansan

Anybody knows any good Jasper report forum (out of javaranch) ?
1 month ago
I found that I kept getting "null" from request.getUserPrincipal() or request.getRemoteUser().  I added


it started returning values.  The application is an internal web application and users only access it from our internal internet.  Can somebody help explain ?
3 months ago

Rob Spoor wrote:Why even store the bean as a session attribute? It's already tied to the session because it's session scoped. Whenever you access it (either using an autowired field or using the context), you will get the instance belonging to the current session - if none existed yet one will be created.



thanks
4 months ago

in java:


Does the java code initialize the bean with name and id and saves it in session ?  But the first parameter of WebUtils.setSessionAttribute is HttpRequest, is that ok ?
4 months ago
Yeah, maybe I should rethink about using Optional<>.  My purpose was just to avoid NPE(NullPointerException)..  If employee object is null it would throw NPE, so in that case I want to use a "default" value to replace the desired employee.getName().   I saw Option<> has some method like "OrElse" etc so I was guessing if I could utilize Optional related method to simplify the old way I have been doing thing like



I was just exploring features of Optional..
4 months ago
For example, if I have a simple case like


Hoever, if employee is null then I get Null pointer exception.
so I can do



How do I do it using java 8 Optional ?
5 months ago
Not very familiar with JSTL.

The original jsp looks like


If I want to apply JSTL fn:someFunction on this firstName variable, should I use

5 months ago
JSP
I am dealing with a legacy spring code base with bunch of possible unused codes.  It is an old spring MVC application.  so from web.xml, I see

and I can allocate these myapp-applicationContext.xml  and myapp-servlet.xml.  Now, I also see another applicationContext type xml file (like myapp-test-applicationContext.xml) spread in other directory, but they are not referred in web.xml or any other xml file, can I say this myapp-test-applicationContext.xml most likely is NOT used in this spring MVC application at all ?  Put it different way, can I assume the actual application context xml file that is used should be referred in web.xml for a spring mvc (old spring) app ?
5 months ago

Carey Brown wrote:I think part of your confusion is that you are not clear about when the issues is with SimpleDateFormatter#format() or SiimpleDateFormatter#parse(). If you parse with "hh" and give it '12' hours it will create the correct number of milliseconds. However, when you use "hh" to reformat it you will get '00' for the hours.



Got it.  I should use HH to format it if I want to see it in 0-24 form, given  it is a timestamp.  But for parsing the timestamp string using hh or HH doesn't make difference.
11 months ago
Actually, wait a min.  I just found something interesting.  hh:mm:ss does not always tolerate a HH:mm:ss when parsing it.  It tolerates it and behaves well in most cases.  But today when I tested it when it was 12:xx:xxSSS ( when it was just aftern noon) it gave problem.  It shows 00:xx:xx.SSS instead of 12:xx:xx.SSS.  So it seems it was confused when the hour is 12, I didn't test how it behaves when it was just after midnight.  So, i guess it is safer to use HH:mm:ss.SSS to parse a timestamp and can't fully trust hh:mm:ss.    Please correct me if you think I am wrong.
11 months ago
Is it true that hibernate data mapping for "Timestamp" type behave differently for DB2 and SQL server ?  
Carey, you wrote
"You are not "formatting" with your SimpleDateFormat, you are using it to parse. So if you declare a time format with "hh" why do you get 24hr time instead of 12hr time? This seems like a logical thing for the parser to do when presented with a number >= 12. So, not surprised. "

-- I know "hh" is 0-12 with AM/PM and I know Timestamp is 0-24 in hours.  So I intentionally use "hh" to parse timestamp when it is in the PM, to see what happens.  I couldn't understand why it parsed OK.  Could you explain little more  ?  Thanks.
11 months ago
Carey, I think I see your point about the 2 digit and 3 digit milli/nano seconds part.  Thanks.  Let me ask about the HH and hh --- Are you saying when I use SimpleDateFormat to parse a Timestamp, it actually doesn't matter if I use "yyyy-MM-dd HH:mm:ss.SSS" or "yyyy-MM-dd hh:mm:ss.SSS" as format to parse ?  Again, please ignore the SSS or SS part, just care the HH and hh for now. Thanks.
11 months ago