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.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
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%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

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, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs