November 27, 2014
Hot Topics:

Extend Your Java Studio Creator Options with JSTL

  • May 4, 2005
  • By Dick Wall
  • Send Email »
  • More Articles »

Deploying a JSTL Enabled Web App

Deploy to Sun App Server PE 8

There are no special steps to deploy this project to the Sun App Server 8 PE. All JSTL libraries necessary to support this project are already provided.

Deploy to Another App Server (Tomcat)

Depending on the App Server you are deploying to, JSTL may not be available in the standard libraries included for that App Server, or it may include an earlier version of the JSTL libraries that is incompatible. For example, Tomcat needs the JSTL libraries to be added to the project that is deployed before it will work.

To include JSTL in the built project WAR file, proceed as follows:

  • Right-click on the Library References section in the project navigator, and select Create New Library Reference.
  • Set the library name to JSTL.
  • Click the add button on the class libraries tab.
  • Navigate to your Creator installation directory, and find the modules/autoload/ext directory.
  • Select both jstl.jar and standard.jar (CTRL-click to select multiple), then click open.
  • Back in the dialog, uncheck the design boxes for both jars, but ensure that the deploy boxes are still checked.
  • Click OK.

This has already been done in the accompanying demo project for this article. Note how, when you select the jars, Creator automatically fills in the {tools.home} path variable, which allows the project to work on other machines with different install locations.

Gotchas

JSTL Nesting Problems

Creator does nesting rule checking, and this is normally a help, but when using JSTL it prevents some common usages of JSTL conditionals nesting.

For example, when I was writing this code for my real project, I actually wanted to highlight the row by changing the background color, doing something like this:

<c:choose>
   <c:when test="${status == -1}">
      <tr bgcolor="red">
   </c:when>
   <c:otherwise>
      <tr bgcolor="green">
   </c:otherwise>
</c:choose>

... rest of table row code here ...
</tr>

Okay, so the default red and green colors for the background might be a bit garish, but the intent is clear, and this is a pattern I have used many times before with the struts tags. However, in practice this fails to compile in Creator because it sees that the nesting of the <tr> and <c:...> tags are messed up (it wants the </tr> paired to the <tr bgcolor>, instead it gets a </c:when> tag first).

This limits what you can do with JSTL inside of Creator at present; hopefully, this will be changed soon to allow more flexibility, but in the meantime you can probably find ways to code around these limitations. If you do find an easy way to color the rows in the manner I was trying above, please let me know and I will incorporate it into a future article (giving you full credit, of course).

Conclusion

Whereas the use of JSTL inside of Creator certainly has its warts, it can be a very useful tool to provide more capability than the Creator controls do on their own. In the past, I have included JavaScript-based tool-tips for rows and cells. Also, the capability of having a scrolling table body is pretty nice. (Note to the Creator guys: Can we have this in a future version of the grid control, please?)

If you have any questions or comments about this or the other articles I have written, please feel free to contact me; Developer.com provides a mechanism to do so.

About the Author

Dick Wall is a Lead Systems Engineer at NewEnergy Associates, a Siemens Company based in Atlanta, GA that provides energy IT and consulting solutions for decision support and energy operations.



Page 3 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel