Stephen Suen

Ranch Hand
+ Follow
since Oct 30, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Stephen Suen

Hi there,

I'm learning JPA. I wonder how to specify a conditional new value in a bulk update. For example:



With JPQL, I can only implement the above native query with two bulk update. Is there any way to do this in a single query?

Thanks for any help.

Stephen
I was totally confused now. Consider following pages in one web application:

/index.jsp (simple welcome file not protected)
/Login.jsp (login page)
/manage/ManageAccount.jsp (some protected resource)

1. request /Login.jsp directly and submit login form
2. authenticated, redirect to the context root, /index.jsp
3. request /manage/ManageAccount.jsp
4. fail and redirect to /Login.jsp
5. click the browser's "Back" button, go back to /index.jsp
6. request /manage/ManageAccount.jsp again, succeed

How could this happen? I'm working on glassfish-v2ur2, using FORM_AUTH with a custom realm for my JSF application.

I read some source code around FormAuthenticator. It seems the server uses some kind of session cache for saving user principles during authentication. Is there any possibility that the above problem comes from this mechanism, or is it just some bug existed in my application?

Thanks for any reply.

Stephen
16 years ago

Originally posted by ou yang:
i remembered a person who have the analogous the question.you would use a filter,the user is not logged in.but they access a protected source then he will be redirected to login page.Once he has successful login in,the user is redirected to the original source page.do you want to do like this?if yes,i will send an example to you .my skype username is xuexishijie,you can add me or send email to me.



Thanks.

For FORM authentication, when unauthenticated users request a protected resource, they will be redirect to login form page, after successful authentication, they will be redirect to the original requested resource. That works for most circumstances. But, if the user goes to the login form directly and submit username/password correctly, he will be authenticated, but not authorized, because the container won't register his principle and role membership to the request object (request.getRemoteUser() == null). This behaviour prevent web application designer from some really simple designs, such as presenting a page with a login box on top of it to allow users login any time they will.

There must be some reasonable consideration the container behaves in this way, but what's that? and any workaround?

Look forward answers

Stephen
16 years ago

Originally posted by Paul Sturrock:

I'm trying to think why you might want them to do this; any reason?


Thanks for the reply.

For example, I want to put a small login form on the top of pages, allows user to submit login form directly as they will, even they never acccess protected resource before this.

Any way, users must access some protected resources so they can submit a login form. This really confused me. I think this behavior will make so many common seen pages difficult to be implemented.
[ November 04, 2008: Message edited by: Stephen Suen ]
16 years ago
I'm working on a web application using form-based authentication on Glassfish V2. When users submit login form directly, i.e. without access to any protected resources, they could be authenticated successfully . But , I found the container won't set any authentication information to the request object, such as user principles in such cases.

I read some sources of the server, it seems the server only registers the users to requests when they access protected resources firstly.

I wonder why the server behaves in this way. If I want to allow users login to the application directly, any suggested workaround?

Stephen Suen
[ November 03, 2008: Message edited by: Stephen Suen ]
16 years ago
Hi,

I'm trying to use exslt:node-set function in my stylesheet, but it's not available in my environment. I did my best to check all possible reasons, but failed.
Can any body help me please?

Here's my simple stylesheet(style.xsl):




When I applied this stylesheet to a simple XML document which contained only an empty
document element. I got this output in screen:

E:\xslt>java -Duser.language=en org.apache.xalan.xslt.Process -in index.xml -xsl
style.xsl -out out.xml
file:///E:/xslt/style.xsl; Line #13; Column #18; XSL verndor:Apache Software Fou
ndation
file:///E:/xslt/style.xsl; Line #25; Column #22; exsl:node-set NOT available
file:///E:/xslt/style.xsl; Line #33; Column #22; math:abs available
file:///E:/xslt/style.xsl; Line #46; Column #22; xalan:nodeset available

And, here's the output XML file (out.xml):


I put only four jars from Xalan-J in my CLASSPATH, you can check this fact from the above output.

Any help will be appreciated.
[ March 28, 2006: Message edited by: Stephen Suen ]

Originally posted by marc weber:
Note: The source for the above quote is...

http://java.sun.com/j2se/1.5.0/docs/guide/language/assert.html



Sorry I forgot to post the link, and thank marc weber help me to do it.
19 years ago
When I read Design FAQ of Assertion, I found such an entry(the last entry on the bottom of the page):

8. Why does an assert statement that executes before its class is initialized behave as if assertions were enabled in the class?

Few programmers are aware of the fact that a class's constructors and methods can run prior to its initialization. When this happens, it is quite likely that the class's invariants have not yet been established, which can cause serious and subtle bugs. Any assertion that executes in this state is likely to fail, alerting the programmer to the problem. Thus, it is generally helpful to the programmer to execute all assertions encountered while in this state.


I know the fact that a class'e constructors and methods can run before its initialization complete, but I still don't understand what the FAQ says.

Anyone can help me please?

Stephen Suen
19 years ago
I'm developing a simple web application under Tomcat 5. I just put my classes directly into WEB-INF/classes. When I recompiled any class and redeploy them to the directory and hope they can be reloaded. But it seemed it won't be dynamically reloaded. I must restart the application or the server.

I wonder whether Tomcat support dynamic class reloading for my classes of web applications?

Stephen
[ July 15, 2005: Message edited by: Stephen Suen ]
19 years ago
Sun PetStore 1.4 demonstrates two difference ServiceLocator implementations for the web tier and the EJB tier:

com.sun.j2ee.blueprints.servicelocator.web.ServiceLocator
com.sun.j2ee.blueprints.servicelocator.ejb.ServiceLocator

The one for the web tier uses the "singleton" strategy and also the "caching" strategy.

I wonder that why we need two different implementations. Is there any problem if we use a single one implementation that uses a cache for both web tier and EJB tier?

Any help will be appreciated.

Stephen
Hi,

XML spec states following VC:Standalone Document Declaration:
"The standalone document declaration MUST have the value "no" if any external markup declarations contain declarations of:
...

element types with element content, if white space occurs directly within any instance of those types."

but why so many tools don't report such error?

sample xml document:

<?xml version='1.0' standalone='yes' ?>
<!DOCTYPE animal SYSTEM "ibm32i04.dtd" [
<!ATTLIST animal xml:space (default|preserve) 'preserve'>
]>
<!-- This is against VC: Standalone Document Declaration in P32
The standalone document declaration has the value "yes", there is an
external markup declaration of element with a element only content type, and
white space occurs directly within the mixed content.
-->
<animal><a>This is a

yellow tiger</a> <b/>
<c/>

</animal>
Hi, all

I notice that in the package java.awt, many methods in the form countXxxs() from JDK1.0 are deprecated and replaced by the form getXxxCount() since JDK1.1. For example, in class java.awt.Container, countComponents() was replaced by getComponentCount().

I'm not sure whether Sun did this only because they adopted new naming convention encouraged, or because of some other more reasonable concerns. I wonder that because I'm trying to follow some convention as I have some methods for the same purpose to be named.

Any help will be appreciated.

Stephen Suen
20 years ago
Hi, Ernest Friedman-Hill,

Thanks for your reply.

I'm confused by some implementations in JDK. For example, java.util.logging.Logger.getHandlers, it returns an array instead of Iterator or Enumeration. The package is since 1.4, so, it's absolutely new code. Based on my limited experience and understanding, I would take Enumeration (not Iterator, because of synchronizing consideration). So, you know, I'm really interested why Sun chose array instead of Enumeration. Is it possible that it's just a personal favor? Otherwise, what's the serious consideration?

Thanks for any advice.

Stephen Suen
21 years ago

Originally posted by Ilja Preuss:
I often prefer to return Arrays, simply because it communicates better the type of the objects in the collection. Of course this will change with Tiger's generics - then I would prefer iterators because they provide better decoupling.



Thanks for your advice, and can you give me more information about "change with Tiger's generics"?

Stephen Suen
21 years ago