views:

8767

answers:

7

Using JDeveloper, I started developing a set of web pages for a project at work. Since I didn't know much about JDev at the time, I ran over to Oracle to follow some tutorials. The JDev tutorials recommended doing JSPX instead of JSP, but didn't really explain why. Are you developing JSPX pages? Why did you decide to do so? What are the pros/cons of going the JSPX route?

+2  A: 

Hello fellow JDeveloper developer!

I have been working with JSPX pages for over two years and I never had any problems with them being JSPX opposed to JSP. The choice for me to go with JSPX was kinda forced since I use JHeadstart to automatically generate ADF Faces pages and by default, JHeadstart generates everything in JSPX.

JSPX specifies that the document has to be a well-formed XML document. This allows stuff to properly and efficiently parse it. I have heard developers say that this helps your pages be more 'future proof' opposed to JSP.

Matthew Ruston
+1  A: 

@Matthew-
ADF! The application I'm presently working on has 90% of the presentation layer generated by mod PL/SQL. I started working on a few new screens and wanted to investigate other options that might fit into our architecture, without being to much of a learning burden (increasing the complexity of the system/crashing developer's mental models of the system) on fellow developers on the team. So ADF is how I came across JSPX, too.

I saw a "future proof" observation as well...but didn't know how well founded that was.

happyappa
+7  A: 

The main difference is that a JSPX file (officially called a 'JSP document') may be easier to work with because the requirement for well-formed XML may allow your editor to identify more typos and syntax errors as you type.

However, there are also disadvantages. For example, well-formed XML must escape things like less-than signs, so your file could end up with content like:

<script type="text/javascript">
   if (number &lt; 0) {

The XML syntax may also be more verbose.

Peter Hilton
Are you **kidding** me?
JDrago
A: 

jpsx is used for ADF applications. The servlet mapping in web.xml will map requests to jspx pages to the ADF Bindings Filter... Do not use jspx unless you are developing using ADF, in which case you will need to.

Zombies
+5  A: 

JSPX has a few inconvenients, on top of my head:

  1. It's hard to generate some kinds of dynamic content; esp. generating an HTML tag with optional attributes (i.e. or depending on a condition). The standard JSP tags which should solve this problem didn't work properly back in the day I started doing JSPX.
  2. No more & nbsp; :-p
  3. You'll really want to put all your Javascript in separate files (or use CDATA sections, etc.). IMHO, you should be using jQuery anyway, so you really don't need to have onclick, etc. attributes...
  4. Tools might not work properly; maybe your IDE does not support anything above plain JSP.
  5. On Tomcat 6.x, at least the versions/config I tried, the generated output does not have any formatting; just a small annoyance, though

On the other hand:

  1. It forces you to write correct XML, which can be manipulated more easily than JSP
  2. Tools might perform instant validation, catching mistakes sooner
  3. Simpler syntax, in my humble opinion
alex
+2  A: 

A totally different line of reasoning why you should use jspx instead of jsp:

JSPX and EL makes including javascript and embedded java codes much harder and much less natural to do than jsp. EL is a language specifically tailored for presentation logic.

All this pushes you towards a cleaner separation of UI rendering and other logic. The disadvantage of lots of embedded code within a JSP(X) page is that it's virtually impossible to test easily, whereas practicing this separation of concerns makes most of your logic fully unit-testable.

krosenvold
+1  A: 

JSPX is also the recommended view technology in Spring MVC / Spring Web Flow.

Hendy Irawan