I know that mixing scriplets and JSTL in JSP is a bad practice, but sometimes you can’t avoid it and every time I do it I can’t remember how to share variables between scriplets and JSTL so this post is a sort of reminder for the future. Hope it can be useful for other forgetful persons like me
Access scriptlet variable with JSTL
<%
String myVariable = "Test";
pageContext.setAttribute("myVariable", myVariable);
%>
<c:out value="myVariable"/>
Access JSTL variable with scriptlet
<c:set var="myVariable" value="Test"/>
<%
String myVariable = (String)pageContext.getAttribute("myVariable");
out.print(myVariable);
%>
Tags: Java, JSP, JSTL, scriptlet, sharing, variables -
I’ve just update the Selective Javascript Loader plugin with some bugfixes and improvements:
- Added the option to choose if Javascript files should be included in the header or in the footer of the page. This option is available only if you are using WordPress 2.8 and above
- Added WordPress version checking.
- Corrected script inclusion for Wordpress 2.7
- Some code optimization
- Corrected a layout bug in the settings page
Read more or download it.
Tags: plugin, projects, Selective Javascript Loader, WordPress -
I’ve just released Selective Javascript Loader my first WordPress plugin. It’s a very simple plugin that automatically loads different Javascript files based on the blog section that is being viewed (index, category, single post, page).
It can be really useful if you make extensive use of Javascript in your theme and want to split the code and load functions only when you need them.
Check it out!
Tags: plugin, projects, Selective Javascript Loader, WordPress -
A simple JavaScript function to check date validity
function checkDateValidity(day, month, year){
month = month - 1;
var message = '';
var date = new Date(year,month,day);
if (year != date.getFullYear())
message = 'Year not valid';
if (month != date.getMonth())
message = 'Month not valid';
if (day != date.getDate())
message = 'Day not valid';
return message;
}
Tags: date, Javascript, validation -