BUT - whenever I try to access this page - I get the following ERROR:
Truncated. see log file for complete stacktrace
I can't understand why - because I think the syntax is valid? Please help - any feedback would be greatly appreciated!!
The first thing you shouldn't have done is write your own login page. Spend time in this forum and you'll see one of my favorite topics to rail against are custom security systems. Because despite the fact that almost every J2EE book ever published has some sort of "login handler" demo in it, in the Real World, custom security systems aren't secure.
The second thing you shouldn't have done is to treat the JSF View definition like it's an old-style JSP with scriptlets. JSF views don't compile into servlets like "real" JSPs do - they're templates, and they shouldn't have logic in them. And, in the case of a commandLink tag, specifically, the commandLink action must be the name of a method in a JSF backing bean, not a URL.
I'm afraid, in fact, that there are so many dodgy practices in your sample that the best thing to do would be to stop coding, get a good introductory book on JSF, and do some serious reading. JSF is very different than other J2EE platforms and the traditional servler/jsp approach doesn't work.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Sep 21, 2011
Dave - Yes, I am using faces - ie, faces/success.jsp
And Tim, though your response is funny and you have some valid points, I am actually NOT posting a login page - this is just a welcome page that attempts to access a "protected" resource. Please don't make assumptions based on a comment in the code.
Now - I agree, the page IS poorly formatted - I am not the original developer and I am just working on migrating this code to a higher version of JSTL/JSF/JDeveloper - so therein lies my problem - stuff like the code below doesn't work and I'm actually not accustomed to working with just JSF alone (Richfaces/MyFAces/IceFAces)....
I will try your suggestion by replacing with just an <a href .... > tag and use the EL notation in there to see if it works - however, in my Core JSF book, apparently the "facesContext" should be available - it's a predefined object in EL.
Thanks for your input - if you have any other suggestions please feel free to comment.
Don't take it personally. I practically have this diatribe wired up to a macro key, since certain offences are so common.
Helping people with JSF carries certain unusual characteristics. People want to do it the way they did older technologies, people want it to be more complicated than it has to be, and - just to make things worse, a lot of stale documentation is still floating around from before JSF got cleaned up enough for everyday use and people use it in ways that are no longer really appropriate.
DIY security systems, however, offend me no matter what the platform, since J2EE is a very expensive technology. Cheap security may be fine for cheap tech, but if we're going to justify our higher costs, we have a certain obligation. So I tend to be touchy about that. Besides, the link DID say "sign in", and that usually means that it's leading to a DIY login screen, not a container-protected URL.
BTW, you can use the "Code" button on our message editor to wrap java code, XML, and other structured text and make it easier to read. I'm afraid that even so, long examples can be hard to read properly on-screen, but it helps.
That commandLink was all wrong from the get-go, though. Firstly, because it should have been referencing a backing bean action method, but even so, commandLinks already know the application context, so they don't need to go rummaging around in JSF internal objects to get it. Like I said, people want JSF to be more complicated than it really is. I've never referenced the FacesContext on a View definition, ever, and I've been working with JSF since before the standard was formally defined.
I had to look twice to see if the sample was even truly JSF, though. It's loaded with raw HTML, which in most cases could have been done simpler using JSF elements. I don't see an "h:form" element, which is mandatory for use of the h:commandLink element, since commandLink is a FORM control, not a hyperlink in the pure HTML (<a href=>) sense.
I wrote some pretty nasty stuff myself when I first started with JSF, so I'm not going to fault this kind of stuff TOO much. However, things can be done better now, and that's what we're here to help with.
Joined: Sep 21, 2011
Well the issue here is: the application is "auto-deployed" to JDev's integrated weblogic server - which automatically generates a context path when it does this type of deployment. This automatically generated context path will not match the context path of the application once I'm done developing ant build/deploy scripts - but for now, I just want it to compile and run successfully in the integrated server.
The issue, then - to re-iterate is that: if I use the following:
- this doesn't automatically put the context path in before the /faces/....
Throws the ReferenceSyntaxException - there are times when either request.contextPath OR (similarly) facesContext.externalContext.request.contextPath - might be needed to access a resource outside of the JSF container (for example) - can anyone tell me WHY the commandLink doesn't work?
Thanks in advance....
Joined: Sep 21, 2011
I was able to get my link working properly by using the following instead of h:commandLink
And now it works - thanks for all your tips....
Now I have a separate issue - which Tim touched on - what is industry accepted practice as far as JSF page formatting goes? OK to mix HTML with JSF/EL/JSTL?