advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

Tutorials : A Brief Introduction to Struts – Expression Language :

General Tags:

One of the most common functions used in a JSP page is displaying the values. This can be accomplished by the tag

<c:out value="The Bean value is ${bean.attribute}" default=" actual value is null" /> 

You can also specify a default value which will be displayed if the attribute is null.

What would you do when you want to set the user Id into session scope or modify some value that is in request scope or application scope in a JSP page? One option is to manipulate the application scoped variable in the actionHandler layer and pass it on to the JSP page by setting the value in the page bean. That is surely an elegant way of doing it but just think of all the trouble if this has to be done for say just one JSP page with one field. The c:set tag can help set and get any scoped values for a JSP page without the hassle of a page bean. The variables can be in page, session, application or request scope.

<c:set value="some Value" var="scopeVarName" scope="request" />

If the value in the above statement is set to null then the scoped variable specified in "var" is removed from the specified scope. The set tag also provides a facility to manipulate a collection or a bean that is in scope.

<c:set value="someValue" target="targetColl" property="keyinColl" />

This could be a request collection or a session collection. The target collection is specified in the target attribute and the field or key to be modified is defined in the property attribute. If the target is a collection (map) then the key that matches the one in the property is retrieved. The retrieved key is used to update the value corresponding to the key in the map. If no key matches the property in the target collection then a new key value pair is created in the collection. If the target is not a Map then it is assumed to be a JavaBean and the c:set follows the general rules for getting and setting values in a JavaBean.

Another common functionality required on a JSP page is exception handling. I used to always get annoyed with the Jasper Runtime exception that is thrown on the JSP page. The exception was annoying as it displays a detailed and mostly useless stack trace for the simplest of errors. The best solution to this problem is to define an error page in the JSP, but the error page is very generic and would be good for critical errors that occur on a page. However for simpler errors like user defined exceptions and missing values, handling the error on the page would give more flexibility to the developer. This is equivalent to enclosing the whole JSP with a try and catch block except that this is a more elegant way of doing it.

<c:catch var="varName">
	Exception Code ….
</c:catch>

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 34
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

IBM Brings Developers Into the Cloud
Apache at 10: You Can't Buy Us
Microsoft's CodePlex Foundation Moving Forward
Apple Claims 100,000 Apps, Google Analyzes Them
Nokia Latest to Play Opera Mobile 10 Browser
PayPal Opens Up Payment Platform to Devs
Ubuntu Linux 9.10 'Karmic Koala' Starts Its Climb
IBM Links Rational Developer Tools, Tivoli Apps
Libraries Give Vista Apps a Windows 7 Look
Ubuntu: The 'Default Alternative' to Windows?

Delivering Web-based Embedded Fonts in CSS 3
Adobe Helps PHP Developers Create Rich Internet Applications
Java Developers Finding a Home at Adobe Flex
Virtualization Delivers a Dynamic Infrastructure
Consuming XML Web Services in iPhone Applications
Build a More Agile Business with IBM
POJO-Based Solutions for LDAP Access: One Good, One Better
IBM Offers Enhanced Measurement and Management for Energy Usage
IBM Helps Transformation to an Information-Based Enterprise
Top Five Touch UI-Related Design Guidelines

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs