• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A few questions of a beginner

 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic