This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hi. I have a few questions, please be patient and tolerant ;-) I am only beginning: 1. what is the use of jsp:text standard action? the JSP 2.0 specs (point 6.3.9) says it must be used when I want to display template text in JSP documents (XML syntax), but actually I have been able to print text without using this action at all, just by putting it in the file, for example within the <body> tags. The only thing that is different that I noticed is that when the jsp:text has only whitespace characters, they are preserved in the output. For exanmple: "<body> </body>" is output as "<body />", and "<body><jsp:text> </jsp:text></body>" is output as "<body> </body>". Is there any other use? 2, point 22.214.171.124 in the specs (page 96), there is a table of possible conversion sources and targets, and its says at the very top, for Bean Property: "As converted by the corresponding PropertyEditor, if any, using PropertyEditor.setAsText(string-literal) and PropertyEditor. getValue(). If there is no corresponding PropertyEditor or the PropertyEditor throws an exception, �null� if the string is empty, otherwise error." So, if there is no property editor, and the string value which is used to set the attribute is empty (""), it should set null to the property. However, tomcat 5.5.26 throws an exception complaining no editor can be found. Is this a violation of the specs, or have I misunderstood something? (I am using jsp:setProperty with value="" to test this.) 3. when I have JSP pages, I can create a servlet element in web.xml for the page, to supply init-params for example. However, there is also an implicit mapping *.jsp(x) in the container, so I can actually access the same page in two ways, using both urls: from the servlet mapping, and the implicit mapping. If the resource is constrained, I would have to create two url-patterns for it or sth? To fix that I came up with two options: use the same url-mapping for the servelt as the actual path to the jsp file in the webapp, or hide the page in WEB-INF. However, the second may be a nuisance, as in this way I would have to explicitly create servlet elements for (possibly many many) all my JSP pages, as resources within WEB-INF and META-INF are protected. How is this problem dealt with?
Originally posted by Raf Szczypiorski: 1. what is the use of jsp:text standard action?
That's only used in the XML document syntax which you should never be using. That syntax is intended for internal use by the containers, or for situations where a JSP will be auto-generated by code. It should never be used by JSP authors to code pages.
2, point 126.96.36.199 in the specs (page 96)
I don't have enough info to answer this, but it's a better question for a Tomcat forum.
3. when I have JSP pages, I can create a servlet element in web.xml for the page, to supply init-params for example
In modern, scriptless JSP pages, this would be considered a really poor practice. JSP pages should be pure templates; view components whose only purpose is to display results. [ September 25, 2008: Message edited by: Bear Bibeault ]
Thank you for your reply. 1. Do you mean I should never ever create JSP documents myself, or do you mean that jsp:xml is only used in XML Views of the page, and I can use standard template text without jsp:text? 3. Suppose I do want to use a JSP for something more than just templating?
If any of these questions (like no.3) is bad practice, I can tell for my excuse that I am studying for SCWCD, and as you may know the exam is pretty theoretical, and it asks questions about something that is not so much used these days (like scriptlets in JSPs), but I still need to know it. Cheers.