aspose file tools*
The moose likes JSP and the fly likes A few questions of a beginner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "A few questions of a beginner" Watch "A few questions of a beginner" New topic
Author

A few questions of a beginner

Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
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 1.14.2.1 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?

Thank you.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

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 1.14.2.1 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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Correct. JSP document syntax is not meant for hand-coding.

JSP is a templating technology. Using it for something else is a misuse of the technology.

Detailed questions for the exam should be asked in the forum devoted to that exam.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A few questions of a beginner