<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3357636544558450315</id><updated>2024-09-24T18:39:02.736+02:00</updated><title type='text'>Pedro Ballesteros</title><subtitle type='html'>Java</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-8146457977026985364</id><published>2011-03-06T00:22:00.000+01:00</published><updated>2011-03-06T00:22:02.644+01:00</updated><title type='text'>Flex y Java con BlazeDS</title><content type='html'>&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span id=&quot;internal-source-marker_0.3824641830287874&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;BlazeDS son unas librerías open source de Adobe, para la integración de Flex y Air con la parte en el servidor de Java. BlazeDS lo utilizaremos en la parte servidor como una aplicación web, que la podremos desplegar en un contenedor de Java Servlets, como Apache Tomcat, Jboss, Weblogic.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Con BlazeDS podremos tener las siguientes características:&lt;/span&gt;&lt;ul&gt;&lt;li style=&quot;background-color: transparent; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Invocación remota de métodos Java desde una aplicación Flex.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;En las peticiones que hagamos desde Flex a Java, &amp;nbsp;podemos pasar objetos AS3 a Java. &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Estos objetos Flex se transformaran a su correspondiente objeto en Java en el servidor.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Al contrario que en el punto anterior, cuando devolvamos un valor de Java a Flex, podremos &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;pasar un objeto Java a la parte cliente de Flex, transformando el objeto Java en su &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;correspondiente objeto en AS3.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Sistema de mensajes entre una aplicación Flex y el servidor de Java, casi en tiempo real.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; color: black; font-family: Verdana; font-size: 10pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Podremos pasar información, datos, desde la parte servidor al cliente en Flex, sin la necesidad de &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;ser una respuesta a una petición del cliente. Digamos que el servidor toma la iniciativa y manda la información sin la existencia de una petición.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Para bajarnos el proyecto BlazeDS, iremos a la dirección &lt;/span&gt;&lt;a href=&quot;http://opensource.adobe.com/wiki/display/blazeds/Downloads&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #000099; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;http://opensource.adobe.com/wiki/display/blazeds/Downloads&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;en esta página nos podemos encontrar dos versiones del proyecto: release builds, que son las versiones estables, testeadas. Por otro lado las nightly builds, que son versiones más recientes, pero que no son tan estables ni están tan testeadas, por lo que pueden contener fallos.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Dentro de las release builds, nos podemos bajar BlazeDS en tres formatos diferentes:&lt;/span&gt;&lt;ul&gt;&lt;li style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;BlazeDS turnkey, en este formato nos bajamos un servidor Apache Tomcat con BlazeDS configurado y listo para usar. En este formato en el servidor vienen ejemplos con su código fuente para probar y aprender la utilización de BlazeDS.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;BlazeDS binary distribution, aquí lo que nos bajamos es BlazeDS como un proyecto web en formato WAR, el cual podemos utilizar como plantilla de nuestros proyectos.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;BlazeDS source en este formato nos bajamos los códigos fuente del proyecto para poder compilarlo nosotros mismos.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;En nuestro caso nos bajaremos de la release builds la opción de BlazeDS turnkey, con la que tendremos un servidor Apache Tomcat listo para probar los ejemplos. Cuando tengamos el fichero zip de BlazeDS turnkey, lo descomprimimos en la ruta que queramos. A partir de ahora si hacemos referencia al directorio raíz, sera el directorio que hemos descomprimido.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Como comentamos anteriormente, BlazeDS se utiliza como una aplicación web, por lo que dentro del directorio raíz podemos encontrar varios ficheros war(web application archive) y algún directorio:&lt;/span&gt;&lt;ul&gt;&lt;li style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;blazeds.war: esta aplicación web la podemos utilizar como plantilla para nuestros proyectos con BlazeDS, nos permite crear un proyecto web vacío, pero con las librerías y ficheros de configuración necesarios para utilizar BlazeDS, así ya solo nos crear nuestro proyecto web sobre este esqueleto.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;samples.war: es un proyecto web con diversos ejemplos de utilización de BazeDS con el código fuente.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;ds-console.war: programa que monitoriza los despliegues de Blazeds.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;/tomcat: directorio con Apache Tomcat en el que están desplegadas las tres aplicaciones de los puntos anteriores.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;/sampledb: instalación del motor de base de datos HSQLDB con las base de datos necesarias para poder ejecutar los ejemplos.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;/resources:directorio con varios recursos, ficheros de configuración, ficheros para configuración de seguridad, puente entre Flex y Ajax.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Una vez que tenemos nuestro BlazeDS en nuestra máquina y sabemos un poco de los ficheros y directorios que trae, vamos a lanzar el Apache Tomcat para poder ver los ejemplos que trae.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Lo primero que tenemos que hacer, es comprobar que tenemos instalado el JDK(Java Development Kit) en nuestra máquina y además tener la variable del sistema JAVA_HOME.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;El segundo paso sería lanzar el motor de base de datos que necesitamos para los ejemplos, para ello iremos al directorio raiz y dentro de el a /sampledb. Aquí ejecutaremos el fichero startdb para lanzar la base de datos en windows, si lo queremos hacer en Linux sería startdb.sh.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Después de esto, ya solo nos queda lanzar el servidor Apache Tomcat. Iremos al directorio raiz, y dentro de este a /tomcat/bin, y aquí ejecutaremos el fichero startup.bat para windows o &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;startup.sh&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; para Linux.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Una vez que tenemos los dos servidores ejecutandose, lo único que nos queda por hacer es abrir en nuestro navegador web la dirección &lt;/span&gt;&lt;a href=&quot;http://localhost:8400/samples/&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #000099; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;http://localhost:8400/samples/&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;. En esta página podemos ver todos los ejemplos de BlazeDS, instrucciones para poder ver el código fuente de los ejemplos y podemos realizar el “Take the test drive” en el que podemos ver ejemplos de lo que podemos hacer con BlazeDS con pequeños ejemplos.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/8146457977026985364/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2011/03/flex-y-java-con-blazeds.html#comment-form' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/8146457977026985364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/8146457977026985364'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2011/03/flex-y-java-con-blazeds.html' title='Flex y Java con BlazeDS'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-553007762076390851</id><published>2011-01-11T23:06:00.000+01:00</published><updated>2011-01-11T23:06:41.342+01:00</updated><title type='text'>Introducción Java y Flex: ejemplo Weather</title><content type='html'>Después&amp;nbsp;de la entrada anterior, en la que explicamos como crear un proyecto con Java y Flex, ahora os dejo otro&amp;nbsp;vídeo&amp;nbsp;con un ejemplo un poco más complejo de una aplicación para predicción del tiempo. Para cualquier duda o sugerencia se aceptan comentarios.&lt;br /&gt;
Os dejo el código fuente del ejemplo&amp;nbsp;&lt;a href=&quot;http://dl.dropbox.com/u/18274657/weather_src.rar&quot;&gt;aquí&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/b82kqQl9XU4?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/553007762076390851/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2011/01/introduccion-java-y-flex-ejemplo.html#comment-form' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/553007762076390851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/553007762076390851'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2011/01/introduccion-java-y-flex-ejemplo.html' title='Introducción Java y Flex: ejemplo Weather'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-7823813593064308588</id><published>2011-01-09T20:44:00.000+01:00</published><updated>2011-01-09T20:44:56.543+01:00</updated><title type='text'>Introducción Java y Flex</title><content type='html'>En esta entrada, os voy a poner mi primer&amp;nbsp;vídeo&amp;nbsp;tutorial. En el hago un pequeño ejemplo sobre como hacer un proyecto Flex para el cliente y su parte del servidor. Es una especie de hola mundo, pero lo que hago es pedir el nombre de usuario en Flex, lo mandamos a la parte servidor y este nos devuelve un mensaje de bienvenida.&lt;br /&gt;
Es un ejemplo básico, pero espero que os sirva, hasta la próxima.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/NzfQZdNp7bY?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/7823813593064308588/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2011/01/introduccion-java-y-flex.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/7823813593064308588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/7823813593064308588'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2011/01/introduccion-java-y-flex.html' title='Introducción Java y Flex'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-2178910263300327287</id><published>2011-01-09T00:59:00.001+01:00</published><updated>2011-01-09T00:59:36.704+01:00</updated><title type='text'>Podcast sobre RIA y Flex</title><content type='html'>Hola y Feliz Año nuevo a todos.&lt;br /&gt;
&lt;br /&gt;
Después de estas vacaciones y de teneros abandonados, empezamos este año publicando un podcast con una pequeña introducción a las aplicaciones RIA y Flex.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;http://dl.dropbox.com/u/18274657/riayflex.mp3&quot;&gt;Podcast Ria y Flex&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Espero que os guste.</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/2178910263300327287/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2011/01/podcast-sobre-ria-y-flex.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/2178910263300327287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/2178910263300327287'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2011/01/podcast-sobre-ria-y-flex.html' title='Podcast sobre RIA y Flex'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-6982591706023819719</id><published>2010-12-12T20:07:00.001+01:00</published><updated>2010-12-30T01:18:41.379+01:00</updated><title type='text'>Quinta Semana</title><content type='html'>Esta semana, con las fiestas, solo hemos tenido dos días de curso. Estos días hemos terminado el blog que&amp;nbsp;estábamos&amp;nbsp;haciendo en Java y JSP, y hemos planteado el desarrollo de un chat con las mismas&amp;nbsp;tecnologías.&lt;br /&gt;
Durante estos dos ejercicios, estamos reforzando las tecnologías de la parte del servidor, Java, JSP y acceso a base de datos y de la parte cliente, HTML y Javascript.&amp;nbsp;También&amp;nbsp;añadimos las&amp;nbsp;librerías&amp;nbsp;de reCAPTCHA&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot;&gt;y añadir a nuestras aplicaciones pluggins de Facebook.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot;&gt;Otra cosa importante que se ha explicado, para la autentificación de usuarios, es el concepto de sesión. La sesión la utilizamos en la parte del servidor mediante la interface &lt;a href=&quot;http://download.oracle.com/javaee/6/api/javax/servlet/http/HttpSession.html&quot;&gt;HTTPSession&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 20px;&quot;&gt;Cuando creamos una aplicación web en Java, siempre que un usuario se conecta con su navegador a la aplicación, se crea un objeto HTTPSession en la memoria del servidor. Este objeto sesión, esta disponible durante todo el tiempo que el usuario esta navegando por la aplicación, de esta manera podemos almacenar objetos específicos para cada usuario durante el tiempo que&amp;nbsp;estén conectados. La sesión se pierde, o se cierra, cuando el usuario cierra el navegador o da la orden a la aplicación de cerrar la sesión. A la sesión&amp;nbsp;también&amp;nbsp;se le puede indicar un tiempo de vida, por lo que se cerrara por el servidor transcurrido dicho intervalo de tiempo.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 20px;&quot;&gt;Como hemos dicho anteriormente, hemos utilizado la sesión para autentificar a los usuarios. Por ejemplo:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: white; color: #330066; font-family: &#39;Arial&#39;; font-size: 8pt;&quot;&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;01 &lt;/span&gt;      HttpSession session &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; request&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getSession&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; true &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;      
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;02 &lt;/span&gt;      String txtUser &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; request&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getParameter&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;txtUser&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;03 &lt;/span&gt;      String txtPassword &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; request&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getParameter&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;txtPassword&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;04 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;05 &lt;/span&gt;      &lt;span style=&quot;color: #ff3030;&quot;&gt;try&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;06 &lt;/span&gt;      &lt;span style=&quot;color: #555555;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;07 &lt;/span&gt;          &lt;span style=&quot;color: #006633;&quot;&gt;//crear el driver&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;08 &lt;/span&gt;          Class&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;forName&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;com.mysql.jdbc.Driver&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;newInstance&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;09 &lt;/span&gt;          con &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; DriverManager&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getConnection&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;jdbc:mysql://localhost/prueba&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;root&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;10 &lt;/span&gt;          &lt;span style=&quot;color: #006633;&quot;&gt;//obtener el statement&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;11 &lt;/span&gt;          pstm &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; con&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;prepareStatement&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &quot;SELECT * FROM usuarios WHERE user = ? AND password = ?&quot; &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;12 &lt;/span&gt;          pstm&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;setString&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #32ba06;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; txtUser &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;13 &lt;/span&gt;          pstm&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;setString&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #32ba06;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; 
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;14 &lt;/span&gt;                  SHA&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;SHA&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; txtPassword &lt;span style=&quot;color: #555555;&quot;&gt;) );&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;15 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;16 &lt;/span&gt;          ResultSet rs &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; pstm&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;executeQuery&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;17 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;18 &lt;/span&gt;          &lt;span style=&quot;color: #ff3030;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; rs&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;() ) {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;19 &lt;/span&gt;            user &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff3030;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #d11ced;&quot;&gt;User&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;20 &lt;/span&gt;            user&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;setId&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; rs&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getInt&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;id&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;) );&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;21 &lt;/span&gt;            user&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;setUser&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; rs&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getString&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;user&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;) );&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;22 &lt;/span&gt;            user&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;setEmail&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; rs&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getString&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;email&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;) );&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;23 &lt;/span&gt;            user&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;setPassword&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; rs&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getString&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;password&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;) );&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;24 &lt;/span&gt;          &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;25 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;26 &lt;/span&gt;          pstm&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;close&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;27 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;28 &lt;/span&gt;          &lt;span style=&quot;color: #ff3030;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; user &lt;span style=&quot;color: #555555;&quot;&gt;!=&lt;/span&gt; null &lt;span style=&quot;color: #555555;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;29 &lt;/span&gt;          &lt;span style=&quot;color: #555555;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;30 &lt;/span&gt;            nextPage &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;/chat.jsp&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;31 &lt;/span&gt;          &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: #ff3030;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;32 &lt;/span&gt;            nextPage &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;/index.jsp&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;33 &lt;/span&gt;          &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;34 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;35 &lt;/span&gt;          session&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;setAttribute&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;user&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; user &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;36 &lt;/span&gt;          request&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getRequestDispatcher&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; nextPage &lt;span style=&quot;color: #555555;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;forward&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; request&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; response &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
Este ejemplo, corresponde a un servlet que controla el login de un usuario. Lo que hacemos en la linea 1 es obtener el objeto sesión del usuario. En las siguientes lineas lo que hacemos es comprobar con una consulta SQL si el usuario esta en la base de datos, y si esta crearnos un bean con la información del usuario. En las lineas 28 - 33, inicializamos la variable &#39;nextPage&#39; dependiendo si el usuario esta creado o no. Y en la linea 35 &amp;nbsp; &amp;nbsp;insertamos el bean usuario en la sesión con el nombre &#39;user&#39;. De esta manera tenemos el bean usuario durante todo el tiempo que el usuario este ejecutando la aplicación y podremos comprobar si ha pasado por el proceso de validación o no. El proceso de validación solamente consistira en comprobar que en la sesión el atributo de nombre &#39;user&#39; no es null.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: white; color: #330066; font-family: &#39;Arial&#39;; font-size: 8pt;&quot;&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;01 &lt;/span&gt;        User user &lt;span style=&quot;color: #555555;&quot;&gt;= (&lt;/span&gt;User&lt;span style=&quot;color: #555555;&quot;&gt;)&lt;/span&gt;request&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getSession&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; true &lt;span style=&quot;color: #555555;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getAttribute&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;user&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;02 &lt;/span&gt;        &lt;span style=&quot;color: #ff3030;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; user &lt;span style=&quot;color: #555555;&quot;&gt;==&lt;/span&gt; null &lt;span style=&quot;color: #555555;&quot;&gt;) {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;03 &lt;/span&gt;            request&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getRequestDispatcher&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;login&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;forward&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; request&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; response &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;04 &lt;/span&gt;        &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
Poniendo este código en cada petición que haga el usuario al servidor, comprobamos si el usuario esta en la sesión o nos devuelve null, en cuyo caso redirigimos al usuario a la pantalla de autentificación de usuario, login.&lt;br /&gt;
Aquí hemos visto como utilizar el objeto sesión para guardar al usuario. Pero la sesión nos puede valer para guardar otros objetos que nos sean necesarios durante la ejecución de nuestra aplicación web para un usuario determinado, puede valernos como un contenedor de objetos&amp;nbsp;útiles&amp;nbsp;para el desarrollo de la aplicación. Otra utilidad, por ejemplo en una tienda online, puede ser guardar en la sesión información relativa al carrito de la compra, o un objeto List con la lista de las cosas que vamos a comprar.&lt;br /&gt;
Como ultimo comentario, decir que hay que procurar llegar a un termino medio a la hora de almacenar objeto en la sesión. Hay que tener en cuenta que la sesión es un objeto que consume recursos del servidor, si decidimos guardar todo en la sesión, y tenemos muchos usuarios conectados,&amp;nbsp;supondrá&amp;nbsp;un consumo de recursos en el servidor, mayormente memoria, por lo que tendremos que tenerlo en cuenta.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/6982591706023819719/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2010/12/quinta-semana.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/6982591706023819719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/6982591706023819719'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2010/12/quinta-semana.html' title='Quinta Semana'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-4580234012295921512</id><published>2010-12-05T21:02:00.047+01:00</published><updated>2010-12-07T20:24:25.413+01:00</updated><title type='text'>Cuarta Semana</title><content type='html'>Aquí estamos en nuestra cuarta semana de curso. Durante esta semana, se nota que ya estamos subiendo el listón de los ejercicios que hacemos, estamos desarrollando aplicaciones que&amp;nbsp;podrían&amp;nbsp;valer para proyectos futuros.&lt;br /&gt;
En cuanto a integración de Java y Flex, hemos desarrollado una aplicación de gestión de contactos. En la parte cliente, en Flex, hemos estado practicando los componentes XMLListCollection, que lo utilizamos como la fuente de datos de un datagrid y el componente HTTPService, con el cual llamamos a la parte del servidor y realizamos las operaciones de edición, borrado e inserción. La parte de servidor, en Java, estamos utilizando servlets para proporcionar los servicios a la aplicación de contactos del cliente.&lt;br /&gt;
Al final de esta semana, se ha propuesto realizar un blog, pero esta vez programado en Java, con Servlets y JSP. Como en el desarrollo del blog vamos a implementar el registro de usuarios, hemos visto como integrar &amp;nbsp;&lt;a href=&quot;http://www.google.com/recaptcha&quot;&gt;reCAPTCHA&lt;/a&gt; en el&amp;nbsp;formulario&amp;nbsp;de registro. Con esto evitamos registros en nuestra aplicación realizados por otros programas, para diferenciar si se registra una persona u otro ordenador.&lt;br /&gt;
Otra cosa que hemos visto, es la manera de gestionar los comentarios de las noticias en el blog, mediante el API de Facebook, de esta manera de una manera sencilla podemos hacer que los comentarios sean gestionados por Facebook. Aparte de esto hemos visto como integrar algunos componentes más en nuestra aplicación.&lt;br /&gt;
&lt;br /&gt;
Aparte de programación, esta semana hemos asistido a una charla sobre emprendedores, donde nos han explicado lo necesario para montar una empresa, con algún ejemplo practico de dos emprendedores que han venido a explicarnos su experiencia. Nos han dado mucha información de donde tenemos que ir para poder conseguir ayudas y orientación para montar una empresa.</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/4580234012295921512/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2010/12/cuarta-semana.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/4580234012295921512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/4580234012295921512'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2010/12/cuarta-semana.html' title='Cuarta Semana'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-9108818097223703923</id><published>2010-12-02T00:25:00.000+01:00</published><updated>2010-12-02T00:25:58.988+01:00</updated><title type='text'>Obtener campo autonumérico de un INSERT en Java</title><content type='html'>En el curso de RIA que estamos realizando, estamos haciendo un ejercicio de una agenda de contactos. Tenemos una pantalla donde enseñamos un listado de los contactos de un &#39;DataGrid&#39;. Cuando insertamos un usuario, mandamos la los datos a&amp;nbsp;través&amp;nbsp;de un &#39;HTTPService&#39; que llama a un servlet.&amp;nbsp;Después&amp;nbsp;en la parte cliente, para no tener que recargar de nuevo todos los datos del datagrid con otra llamada al servidor, insertamos un nodo nuevo en el &#39;XMLListCollection&#39; que hace de data provider de&amp;nbsp;nuestro&amp;nbsp;datagrid.&lt;br /&gt;
Hasta aquí todo va bien, el problema es que cuando insertamos el nodo nuevo es necesario que la llamada al servicio de insertar nos devuelva el id que se ha creado nuevo en la base de datos(valor autonumérico), para en un futuro poder manipular ese contacto nuevo, por ejemplo si lo queremos borrar.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: white; color: #330066; font-family: &#39;Arial&#39;; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;01 &lt;/span&gt;          Class&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;forName&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;com.mysql.jdbc.Driver&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;newInstance&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;02 &lt;/span&gt;          conn &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; DriverManager&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getConnection&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;jdbc:mysql://localhost/ria&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;usr&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;pwd&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;03 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;04 &lt;/span&gt;          stm &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; conn&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;createStatement&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;05 &lt;/span&gt;          stm&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;executeUpdate&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;INSERT INTO usuarios ( nombre, apellidos )&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;+&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;06 &lt;/span&gt;              &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;VALUES ( &#39;Alfonso&#39;, &#39;Pérez&#39; )&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; Statement&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;RETURN_GENERATED_KEYS &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;07 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;08 &lt;/span&gt;          &lt;span style=&quot;color: #f48c23;&quot;&gt;int&lt;/span&gt; id &lt;span style=&quot;color: #555555;&quot;&gt;= -&lt;/span&gt;&lt;span style=&quot;color: #32ba06;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;09 &lt;/span&gt;          ResultSet rs &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; stm&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getGeneratedKeys&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;10 &lt;/span&gt;          &lt;span style=&quot;color: #ff3030;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; rs&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;() ) {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;11 &lt;/span&gt;            id &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; rs&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getInt&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #32ba06;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;12 &lt;/span&gt;          &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;13 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;14 &lt;/span&gt;          stm&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;close&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
El primer cambio que tendremos que hacer para obtener el autonumérico, es cuando hacemos la llamada al método &#39;executeUpdate&#39;, además de pasar como parámetro el SQL, tenemos que pasar la constante que indica que nos devuelva los valores generados. Esta opción no es necesaria en algunas ocasiones, podemos omitir este parámetro, pero en algunas base de datos sino lo ponemos no nos devuelve el valor generado, por lo que cuando queramos los valores autonuméricos, estaría bien añadir este parámetro.&lt;br /&gt;
El segundo cambio, de la linea 8 a la 12, es donde&amp;nbsp;obtenemos&amp;nbsp;el valor generado con la llamada a &#39;stm.getGeneratedKeys&#39;. Este método nos devuelve los valores en un ResultSet, por lo que lo trataremos como a otro ResultSet cualquiera. Como vemos en el código de ejemplo, mi tabla solo tiene un campo de tipo autonumérico, por lo que el valor lo obtenemos con &#39;rs.getInt(1)&#39;, si&amp;nbsp;tuviéramos&amp;nbsp;más de un campo lo&amp;nbsp;obtendríamos&amp;nbsp;con el indice del mismo, empezando en 1.</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/9108818097223703923/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2010/12/obtener-campo-autonumerico-de-un-insert.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/9108818097223703923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/9108818097223703923'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2010/12/obtener-campo-autonumerico-de-un-insert.html' title='Obtener campo autonumérico de un INSERT en Java'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-8453397928922109473</id><published>2010-11-28T01:01:00.032+01:00</published><updated>2010-11-28T09:30:38.351+01:00</updated><title type='text'>Seguridad en nuestra aplicación con Servlet Filter</title><content type='html'>En mi anterior entrada os comentaba que para ver un ejemplo de cookies,&amp;nbsp;habíamos&amp;nbsp;hecho una pequeña aplicación en la que&amp;nbsp;teníamos&amp;nbsp;una pagina de login que al autenticarse,&amp;nbsp;creábamos&amp;nbsp;una cookie para indicar que&amp;nbsp;estábamos&amp;nbsp;autorizados para navegar por la aplicación.&lt;br /&gt;
&lt;pre style=&quot;background-color: white; color: #330066; font-family: &#39;Arial&#39;; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;01 &lt;/span&gt;            Cookie miCookie &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff3030;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #d11ced;&quot;&gt;Cookie&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;logged&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;true&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;02 &lt;/span&gt;            miCookie&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;setMaxAge&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #32ba06;&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #32ba06;&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #32ba06;&quot;&gt;24&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;03 &lt;/span&gt;            response&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;addCookie&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; miCookie &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;&lt;/pre&gt;Con este&amp;nbsp;código, creamos la cookie para saber que estamos autenticados. Entonces para poder proteger todas las páginas de la aplicación o todas las peticiones que hagamos al servidor, tendremos que&amp;nbsp;comprobar&amp;nbsp;que la cookie que nos indica que estamos autorizados esta creada y con el valor correcto,y en el caso de que no estemos autorizados dirigirlo a la pantalla de login.&lt;br /&gt;
&lt;pre style=&quot;background-color: white; color: #330066; font-family: &#39;Arial&#39;; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;01 &lt;/span&gt;    Cookie&lt;span style=&quot;color: #555555;&quot;&gt;[]&lt;/span&gt; cookies &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; request&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getCookies&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;02 &lt;/span&gt;    &lt;span style=&quot;color: #f48c23;&quot;&gt;boolean&lt;/span&gt; logged &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; false&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;03 &lt;/span&gt;    
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;04 &lt;/span&gt;    &lt;span style=&quot;color: #ff3030;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; cookies &lt;span style=&quot;color: #555555;&quot;&gt;!=&lt;/span&gt; null &lt;span style=&quot;color: #555555;&quot;&gt;) {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;05 &lt;/span&gt;        &lt;span style=&quot;color: #ff3030;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #f48c23;&quot;&gt;int&lt;/span&gt; i&lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #32ba06;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #555555;&quot;&gt;&amp;lt;&lt;/span&gt; cookies&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;length&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #555555;&quot;&gt;++ ) {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;06 &lt;/span&gt;            Cookie cookieActual &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; cookies&lt;span style=&quot;color: #555555;&quot;&gt;[&lt;/span&gt;i&lt;span style=&quot;color: #555555;&quot;&gt;];&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;07 &lt;/span&gt;            String identificador &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; cookieActual&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getName&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;08 &lt;/span&gt;            String valor &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; cookieActual&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getValue&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;09 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;10 &lt;/span&gt;            &lt;span style=&quot;color: #ff3030;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; identificador&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;logged&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;) &amp;amp;&amp;amp;&lt;/span&gt; valor&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;true&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;) ) {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;11 &lt;/span&gt;                logged &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; true&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;12 &lt;/span&gt;            &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;13 &lt;/span&gt;        &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;14 &lt;/span&gt;    &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt; 
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;15 &lt;/span&gt;    &lt;span style=&quot;color: #ff3030;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;( !&lt;/span&gt;logged &lt;span style=&quot;color: #555555;&quot;&gt;) {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;16 &lt;/span&gt;        request&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getRequestDispatcher&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;/login.jsp&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;forward&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; request&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; response &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;17 &lt;/span&gt;    &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;Con este código hacemos la comprobación de que el usuario esta autorizado, el problema es que tendremos que repetir en cada página o petición a un servlet la comprobación de las cookies.&lt;br /&gt;
Existe otra manera de centralizar la&amp;nbsp;comprobación&amp;nbsp;de las cookies para ver si el usuario ha pasado por el proceso de autorización, y no tener que preocuparnos cada vez que creemos una página nueva. En las aplicaciones de servidor con Java EE, existe un componente que son unos filtros. Estos filtros se activan antes de ejecutar en el servidor un servlet o un path concreto dentro de nuestra aplicación web. Para configurar un filtro lo que haremos sera crear una clase que implemente el interface javax.servlet.Filter y mediante anotaciones indicar su &amp;nbsp;nombre y una ruta a filtrar.&lt;br /&gt;
&lt;pre style=&quot;background-color: white; color: #330066; font-family: &#39;Arial&#39;; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;01 &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;@WebFilter&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt;filterName&lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;Security&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; urlPatterns&lt;span style=&quot;color: #555555;&quot;&gt;={&lt;/span&gt;&lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;/*&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;})&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;02 &lt;/span&gt;&lt;span style=&quot;color: #ff3030;&quot;&gt;public class&lt;/span&gt; Security &lt;span style=&quot;color: #ff3030;&quot;&gt;implements&lt;/span&gt; Filter&lt;/pre&gt;En el ejemplo que he puesto se crea una clase que implementa el interface&amp;nbsp;javax.servlet.Filter, le llamamos&amp;nbsp;Security y hacemos que se active para cualquier llamada a algún recurso de nuestra aplicación mediante &#39;/*&#39;, cualquier ruta ha partir del raiz de nuestra aplicación web.&lt;br /&gt;
Cuando se activa nuestro filtro, se llama a la función definida en el interface &#39;doFilter(ServletRequest request, ServletResponse response,&amp;nbsp;FilterChain chain)&#39;. &amp;nbsp;Los&amp;nbsp;parámetros de este método son los mismos que&amp;nbsp;recibiríamos&amp;nbsp;en un servlet( request y response ) y ademas el objeto FilterChain, que lo utilizaremos para que &amp;nbsp;la petición al servidor siga su camino y se ejecute normalmente. Pueden existir definidos más de un filtro, los cuales se&amp;nbsp;irán&amp;nbsp;ejecutando uno&amp;nbsp;detrás&amp;nbsp;de otro hasta terminar con la ejecución de la petición al servidor.&lt;br /&gt;
&lt;pre style=&quot;background-color: white; color: #330066; font-family: &#39;Arial&#39;; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;01 &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;@WebFilter&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt;filterName&lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;Security&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; urlPatterns&lt;span style=&quot;color: #555555;&quot;&gt;={&lt;/span&gt;&lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;/*&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;})&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;02 &lt;/span&gt;&lt;span style=&quot;color: #ff3030;&quot;&gt;public class&lt;/span&gt; Security &lt;span style=&quot;color: #ff3030;&quot;&gt;implements&lt;/span&gt; Filter
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;03 &lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;04 &lt;/span&gt;    &lt;span style=&quot;color: #ff3030;&quot;&gt;private&lt;/span&gt; FilterConfig filterConfig &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; null&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;05 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;06 &lt;/span&gt;    &lt;span style=&quot;color: #ff3030;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #d11ced;&quot;&gt;Security&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;() {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;07 &lt;/span&gt;    &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;08 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;09 &lt;/span&gt;    &lt;span style=&quot;color: blue;&quot;&gt;@Override&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;10 &lt;/span&gt;    &lt;span style=&quot;color: #ff3030;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #f48c23;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d11ced;&quot;&gt;doFilter&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; ServletRequest request&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; ServletResponse response&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;11 &lt;/span&gt;                         FilterChain chain &lt;span style=&quot;color: #555555;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #ff3030;&quot;&gt;throws&lt;/span&gt; IOException&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; ServletException
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;12 &lt;/span&gt;    &lt;span style=&quot;color: #555555;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;13 &lt;/span&gt;      Cookie&lt;span style=&quot;color: #555555;&quot;&gt;[]&lt;/span&gt; cookies &lt;span style=&quot;color: #555555;&quot;&gt;= ((&lt;/span&gt;HttpServletRequest&lt;span style=&quot;color: #555555;&quot;&gt;)&lt;/span&gt;request&lt;span style=&quot;color: #555555;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getCookies&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;14 &lt;/span&gt;      &lt;span style=&quot;color: #f48c23;&quot;&gt;boolean&lt;/span&gt; logged &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; false&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;15 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;16 &lt;/span&gt;      &lt;span style=&quot;color: #ff3030;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; cookies &lt;span style=&quot;color: #555555;&quot;&gt;!=&lt;/span&gt; null &lt;span style=&quot;color: #555555;&quot;&gt;) {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;17 &lt;/span&gt;          &lt;span style=&quot;color: #ff3030;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #f48c23;&quot;&gt;int&lt;/span&gt; i&lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #32ba06;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #555555;&quot;&gt;&amp;lt;&lt;/span&gt; cookies&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;length&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #555555;&quot;&gt;++ ) {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;18 &lt;/span&gt;              Cookie cookieActual &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; cookies&lt;span style=&quot;color: #555555;&quot;&gt;[&lt;/span&gt;i&lt;span style=&quot;color: #555555;&quot;&gt;];&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;19 &lt;/span&gt;              String identificador &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; cookieActual&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getName&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;20 &lt;/span&gt;              String valor &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; cookieActual&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getValue&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;21 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;22 &lt;/span&gt;              &lt;span style=&quot;color: #ff3030;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; identificador&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;logged&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;) &amp;amp;&amp;amp;&lt;/span&gt; valor&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;true&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;) ) {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;23 &lt;/span&gt;                  logged &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; true&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;24 &lt;/span&gt;              &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;25 &lt;/span&gt;          &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;26 &lt;/span&gt;      &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;27 &lt;/span&gt;      &lt;span style=&quot;color: #ff3030;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;( !&lt;/span&gt;logged &lt;span style=&quot;color: #555555;&quot;&gt;) {&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;28 &lt;/span&gt;          request&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;getRequestDispatcher&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;/login.jsp&quot;&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;forward&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt; request&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; response &lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;29 &lt;/span&gt;      &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: #ff3030;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #555555;&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;30 &lt;/span&gt;        chain&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;doFilter&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt;request&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt;response&lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;31 &lt;/span&gt;      &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;32 &lt;/span&gt;    &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;33 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;34 &lt;/span&gt;    &lt;span style=&quot;color: blue;&quot;&gt;@Override&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;35 &lt;/span&gt;    &lt;span style=&quot;color: #ff3030;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #f48c23;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d11ced;&quot;&gt;destroy&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;() {&lt;/span&gt; 
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;36 &lt;/span&gt;    &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;37 &lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;38 &lt;/span&gt;    &lt;span style=&quot;color: blue;&quot;&gt;@Override&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;39 &lt;/span&gt;    &lt;span style=&quot;color: #ff3030;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #f48c23;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d11ced;&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt;FilterConfig filterConfig&lt;span style=&quot;color: #555555;&quot;&gt;) {&lt;/span&gt; 
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;40 &lt;/span&gt;      &lt;span style=&quot;color: #ff3030;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;filterConfig &lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt; filterConfig&lt;span style=&quot;color: #555555;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;41 &lt;/span&gt;    &lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;42 &lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;Como se puede ver en el código, el cuerpo del método doFilter es el mismo que&amp;nbsp;poníamos&amp;nbsp;al principio de esta entrada pero&amp;nbsp;añadiéndole&amp;nbsp;la linea &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #330066; font-family: Arial; font-size: 13px; white-space: pre;&quot;&gt;chain&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #330066; font-family: Arial; font-size: 13px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #555555;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #330066; font-family: Arial; font-size: 13px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #d11ced;&quot;&gt;doFilter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #330066; font-family: Arial; font-size: 13px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #330066; font-family: Arial; font-size: 13px; white-space: pre;&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #330066; font-family: Arial; font-size: 13px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #330066; font-family: Arial; font-size: 13px; white-space: pre;&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #330066; font-family: Arial; font-size: 13px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #555555;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;. Con esta linea, si la autentificación ha ido bien, indicamos que&amp;nbsp;continué&amp;nbsp;con el siguiente filtro o realice la petición que se ha hecho al servidor.&amp;nbsp;De esta manera solo hemos creado el código de verificación de usuario en el filtro, cada vez que llamemos a algún recurso de nuestra aplicación se ejecutara el filtro y comprobaremos si el usuario esta autorizado. Ya no necesitamos preocuparnos de repetir el código en todas las páginas o servlets que creemos nuevos.&lt;br /&gt;
Otra cosa que&amp;nbsp;podríamos&amp;nbsp;hacer, sería hacer que el filtro solo actuara en parte de nuestra aplicación web, de esta manera&amp;nbsp;tendríamos&amp;nbsp;parte visible a cualquiera y otra parte solo disponible a usuarios autorizados.&lt;br /&gt;
Por ejemplo se pueden definir los servlets privados de la siguiente manera&lt;br /&gt;
&lt;pre style=&quot;background-color: white; color: #330066; font-family: &#39;Arial&#39;; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;01 &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;@WebServlet&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt;name&lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;Login&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; urlPatterns&lt;span style=&quot;color: #555555;&quot;&gt;={&lt;/span&gt;&lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;/private/users&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;})&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;02 &lt;/span&gt;&lt;span style=&quot;color: #ff3030;&quot;&gt;public class&lt;/span&gt; Login &lt;span style=&quot;color: #ff3030;&quot;&gt;extends&lt;/span&gt; HttpServlet&lt;/pre&gt;Aquí definimos un servlet dentro de &#39;private&#39;, entonces lo que haremos es definir el filtro para los recursos dentro de private&lt;br /&gt;
&lt;pre style=&quot;background-color: white; color: #330066; font-family: &#39;Arial&#39;; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: #9a9a9a;&quot;&gt;01 &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;@WebFilter&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;(&lt;/span&gt;filterName&lt;span style=&quot;color: #555555;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;Security&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;,&lt;/span&gt; urlPatterns&lt;span style=&quot;color: #555555;&quot;&gt;={&lt;/span&gt;&lt;span style=&quot;color: #1861a7;&quot;&gt;&quot;/private/*&quot;&lt;/span&gt;&lt;span style=&quot;color: #555555;&quot;&gt;})&lt;/span&gt;
&lt;span style=&quot;color: #9a9a9a;&quot;&gt;02 &lt;/span&gt;&lt;span style=&quot;color: #ff3030;&quot;&gt;public class&lt;/span&gt; Security &lt;span style=&quot;color: #ff3030;&quot;&gt;implements&lt;/span&gt; Filter&lt;/pre&gt;Ahora hemos definido el filtro para lo que se encuentre definido en &#39;private&#39;.</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/8453397928922109473/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2010/11/crear-un-filtro-en-nuestra-aplicacion.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/8453397928922109473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/8453397928922109473'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2010/11/crear-un-filtro-en-nuestra-aplicacion.html' title='Seguridad en nuestra aplicación con Servlet Filter'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-7093023693244598390</id><published>2010-11-27T00:44:00.001+01:00</published><updated>2010-11-27T00:46:05.631+01:00</updated><title type='text'>Tercera semana</title><content type='html'>En cuanto a Java esta semana, hemos visto un poco como&amp;nbsp;podíamos&amp;nbsp;hacer para tener el control de las páginas para solo ser vistas por usuarios autorizados. Hemos visto una introducción a las cookies y las sesiones. Una de las principales diferencias entre ambas, es que la información de las cookies se guarda en el cliente, y la información de las sesiones se guarda en la parte del servidor.&lt;br /&gt;
Para probar las cookies, hemos hecho una aplicación web con una pantalla de login, un registro de usuario y una &amp;nbsp;pagina principal que a la cual entramos una vez hemos realizado el login. Para evitar que&amp;nbsp;después&amp;nbsp;de autenticarse, un usuario pueda entrar en la página home u otra dentro de la web sin pasar por el login, hemos añadido un código en cada página, que comprueba mediante las cookies, que el usuario ya ha sido validado.&lt;br /&gt;
&lt;br /&gt;
Otra cosa que se ha comentado un poco, hemos visto un algoritmo para hacerlo, es el encriptar la contraseña del usuario. Una vez que enviamos la contraseña del cliente al servidor, allí la encriptamos y la guardamos en base de datos. En el servidor todo el tratamiento que le demos a la contraseña, se&amp;nbsp;hará estando encriptada, de esta manera conservamos su privacidad.&lt;br /&gt;
&lt;br /&gt;
Por fin esta semana hemos instalado &lt;a href=&quot;http://www.adobe.com/es/products/flashbuilder/&quot;&gt;Flash Builder&lt;/a&gt;( basado en &lt;a href=&quot;http://es.wikipedia.org/wiki/Eclipse_(software)&quot;&gt;Eclipse&lt;/a&gt;), la versión 4 de Flex y la versión 3 de ActionScript. Es una mejora enorme respecto a el entorno de desarrollo que hemos utilizado hasta ahora, asistente de código, desarrollo visual de las pantallas, asistentes para conexión a servicios web...&lt;br /&gt;
Con Flex, hemos aprendido algunos componentes para la navegación por una aplicación, por ejemplo el TabNavigator, ViewStack, Accordion. Con estos controles podemos navegar entre distintas opciones o formularios dentro de nuestra aplicación, uno de los más conocidos por todos son las pestañas(tabs).&lt;br /&gt;
&lt;br /&gt;
Dentro de la parte de los formularios, hemos aprendido a validar los campos y a formatear las entradas de los usuarios, de esta manera cuando vayamos a enviar el formulario al servidor nos aseguramos que mandamos todos los datos necesarios en el formato que necesitamos.&lt;br /&gt;
El viernes hemos visto un ejemplo de integración de Flex con Java, de esta manera ya tenemos todo el ciclo cerrado, y somos capaces de desarrollar una interfaz en Flex que se comunica con la parte Java en el servidor, para poder por manipular la información que tenemos en la base de datos y poder mostrarla en el navegador.&lt;br /&gt;
En cuanto a ejercicios que hemos hecho esta semana, podemos ver una aplicación en Flex para autenticar y registrar un usuario.&amp;nbsp;También&amp;nbsp;se ha propuesto para la semana que viene integrarla con la parte del servidor, java y MySQL. Una aplicación que me ha gustado es el desarrollo del juego del ahorcado hecho con Flex.</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/7093023693244598390/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2010/11/en-cuanto-java-esta-semana-hemos-visto.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/7093023693244598390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/7093023693244598390'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2010/11/en-cuanto-java-esta-semana-hemos-visto.html' title='Tercera semana'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-3023738418537621969</id><published>2010-11-21T22:36:00.000+01:00</published><updated>2010-11-21T01:45:42.024+01:00</updated><title type='text'>Dos Semanas</title><content type='html'>Bueno pues ya han pasado dos semanas de curso. Esta semana hemos empezado con Java, iremos alternando Flex y Java para al final programar con los dos juntos, el &lt;a href=&quot;http://es.wikipedia.org/wiki/Front-end_y_back-end&quot;&gt;front-end&lt;/a&gt; con Flex y el &lt;a href=&quot;http://es.wikipedia.org/wiki/Front-end_y_back-end&quot;&gt;back-end&lt;/a&gt; con Java.&lt;br /&gt;
Hemos estado aclarando algunos conceptos básicos de Java, como clases, objetos, herencia, interfaces...&amp;nbsp;También se ha hablado un poco de&amp;nbsp;metodología, de forma de hacer las cosas y trabajar en equipo.&lt;br /&gt;
En cuanto a Java hemos pasado&amp;nbsp;rápidamente a lo que nos va a interesar más, a la parte del servidor. Estamos haciendo muchos ejemplos sobre Servlets y JSP, que digamos es el comienzo para poder hacer una aplicación web. Las aplicaciones las estamos desarrollando en &lt;a href=&quot;http://es.wikipedia.org/wiki/NetBeans&quot;&gt;NetBeans&lt;/a&gt; y las desplegamos en el servidor &lt;a href=&quot;http://es.wikipedia.org/wiki/GlassFish&quot;&gt;GlashFish&lt;/a&gt;.&lt;br /&gt;
Otra cosa que&amp;nbsp;también&amp;nbsp;estamos utilizando es la parte de Java para el manejo de bases de datos, JDBC. Para ello estamos utilizando el servidor &lt;a href=&quot;http://es.wikipedia.org/wiki/MySQL&quot;&gt;MySQL&lt;/a&gt;.&lt;br /&gt;
Como novedad esta semana hemos empezado con el curso de ingles, hemos dado un día de clase, y aunque&amp;nbsp;parecía&amp;nbsp;que&amp;nbsp;iba a ser demasiado cinco horas seguidas, la clase a sido amena, con actividades en la que hemos participado todos.&lt;br /&gt;
Pues nada más, otra semana bastante completa y llena de cosas nuevas. Con lo que llevamos de curso, se&amp;nbsp;podría&amp;nbsp;decir que seria capaz de hacer ya alguna pequeña aplicación en Flex con Java, aunque&amp;nbsp;todavía&amp;nbsp;nos quedan muchos puntos por aprender.</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/3023738418537621969/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2010/11/dos-semanas.html#comment-form' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/3023738418537621969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/3023738418537621969'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2010/11/dos-semanas.html' title='Dos Semanas'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-6246832605221282417</id><published>2010-11-14T18:16:00.000+01:00</published><updated>2010-11-14T18:16:45.186+01:00</updated><title type='text'>Una Semana</title><content type='html'>Bueno, pues ya hemos cumplido la primera semana de curso, aunque solo han sido tres días de clase. La verdad es que por ahora el curso esta cumpliendo mis&amp;nbsp;expectativas. Hace unos años hice un curso parecido a este pero&amp;nbsp;cubría&amp;nbsp;otras&amp;nbsp;tecnologías, y os puedo asegurar que con el ritmo que llevamos ya lo veo más interesante y mucho mejor.&lt;br /&gt;
El temario que hemos visto esta semana ha sido bastante, con lo que hemos aprendido se pueden hacer algunas cosas ya, y si uno domina algún lenguaje de servidor, incluso puede hacer el mantenimiento de alguna base de datos que tenga. Hemos visto una introducción a lo que significa &lt;a href=&quot;http://es.wikipedia.org/wiki/Rich_Internet_Application&quot;&gt;RIA&lt;/a&gt;&amp;nbsp;y la hemos enfocado a Flex.&lt;br /&gt;
De Flex hemos aprendido la estructura básica de una aplicación, algunos componentes para poder hacer formularios y enseñar información, como compilarlo y probarlo en un navegador. Aparte de crear pantallas&amp;nbsp;también&amp;nbsp;sabemos como a&amp;nbsp;través&amp;nbsp;de HTTP llamar a servicios, recoger la información y presentarla de una manera &amp;nbsp;amigable para el usuario.&lt;br /&gt;
&lt;br /&gt;
Otra cosa que me gusta, es que aparte del temario, estamos viendo temas interesantes. Por ejemplo hacen mucho&amp;nbsp;hincapié en &lt;a href=&quot;http://es.wikipedia.org/wiki/Web_2.0&quot;&gt;Web 2.0&lt;/a&gt;, de esta manera estamos viendo herramientas de Google, tenemos que tener un blog con información del curso y sobre lo que queramos, miraremos redes sociales...</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/6246832605221282417/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2010/11/una-semana.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/6246832605221282417'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/6246832605221282417'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2010/11/una-semana.html' title='Una Semana'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3357636544558450315.post-8236642596514505501</id><published>2010-11-13T16:51:00.000+01:00</published><updated>2010-11-13T16:51:14.860+01:00</updated><title type='text'>Mi primera entrada</title><content type='html'>Hola a todos mis posibles lectores. He creado este blog en un curso sobre aplicaciones RIA con Flex y Java que hemos empezado esta semana. Durante el curso os&amp;nbsp;iré&amp;nbsp;hablando sobre lo que aprendemos, noticias de&amp;nbsp;interés, e intentare escribir cosas sobre Flex y Java que espero que sean&amp;nbsp;útiles.&amp;nbsp;Espero veres por aquí muy a menudo.</content><link rel='replies' type='application/atom+xml' href='http://pballesterosm.blogspot.com/feeds/8236642596514505501/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pballesterosm.blogspot.com/2010/11/mi-primera-entrada.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/8236642596514505501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3357636544558450315/posts/default/8236642596514505501'/><link rel='alternate' type='text/html' href='http://pballesterosm.blogspot.com/2010/11/mi-primera-entrada.html' title='Mi primera entrada'/><author><name>Pedro Ballesteros</name><uri>http://www.blogger.com/profile/09719013657493478466</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>