Warning: error_log(/home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.log) [function.error-log]: failed to open stream: Permission denied in /home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php on line 986

Warning: error_log(/home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.log) [function.error-log]: failed to open stream: Permission denied in /home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php on line 986

Warning: error_log(/home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.log) [function.error-log]: failed to open stream: Permission denied in /home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php on line 986

PicaTeclas

8Jun/100

Acceder a una variable de scriplet con JSTL (y viceversa)

Aunque mezclar scriptlets y JSTL en las páginas JSP es una mala práctica (hace el código mucho más difícil de mantener), a veces es complicado de evitar tener que compartir variables entre código java incrustado en los JSP (scriptlets) y las etiquetas JSTL. Para poder compartir valores de variable entre ambos existe el contexto de la página:

Acceder a una variable de un scriptlet con JSTL

<% String miVariable = "Cadena"; pageContext.setAttribute("miVariable", miVariable); %>
<c:out value="miVariable"/>

Acceder a una variable de JSTL mediante scriptlets

<c:set var="miVariable" value="Cadena"/>
<%
String miVariable= (String)pageContext.getAttribute("miVariable");
out.print(miVariable);
%>

Las variables usadas pueden ser objetos complejos, siempre que se importen mediante

<%@page import="paquete.nombre.de.la.clase"%>

Vía | Alessandro Melandri.

11Dic/080

Rotar una BufferedImage en Java

Me he llevado cierto tiempo encontrar una función para conseguir rotar 90 grados una imagen de tipo BufferedImage en Java, así que una vez he hallado cómo hacerlo qué menos que compartirlo por si os es útil:

	 public BufferedImage rotate90DX(BufferedImage bi)
	    	{
	    		int width = bi.getWidth();
	    		int height = bi.getHeight();
 
	    		BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
 
	    		for(int i=0; i<width; i++)
	    			for(int j=0; j<height; j++)
	    				biFlip.setRGB(height-1-j, width-1-i, bi.getRGB(i, j));
 
	   		return biFlip;
	  }

Y en el sentido inverso sería así...

	    	public BufferedImage rotate90SX(BufferedImage bi)
	    	{
	    		int width = bi.getWidth();
	    		int height = bi.getHeight();
 
	    		BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
 
	    		for(int i=0; i<width; i++)
	    			for(int j=0; j<height; j++)
	    				biFlip.setRGB(j, i, bi.getRGB(i, j));
 
	    		return biFlip;
	    	}

Vía | Snippet en Dzone.