<?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: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-5570544920231772495</id><updated>2011-07-30T15:02:56.538-07:00</updated><title type='text'>Java Developers MID.</title><subtitle type='html'>El blog de un amante de los sistemas, principalmente de los hechos en java. bueno también algunos comentarios de otras cosas.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>22</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-7593644383489709559</id><published>2011-05-05T10:51:00.000-07:00</published><updated>2011-05-09T22:27:34.477-07:00</updated><title type='text'>Query's dinamicos.</title><content type='html'>En esta ocasión les muestro un código que sirve para crear un preparedStatement con valores de búsqueda variables,  estos se pueden agregar a voluntad con la interface &lt;a href="http://download.oracle.com/javase/6/docs/api/java/util/TreeMap.html"&gt;TreeMap&lt;/a&gt; , esto permite generar query's de manera dinámica a la hora de hacer consultas,  pudiendo poner uno o mas parámetros sin tener que escribir excesivo código con if-else a la hora de programar,  esto nos permite hacer menos código a la hora de programar busquedas en sql, y combinar criterios sin tener que pelear demasiado a la hora de codificar, el resultado del método es una sentencia preparada. la cual solo necesita ser ejecutada y para regresar el set de resultados.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="width: 520px; height: 500px; overflow: auto;"&gt;&lt;br /&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * Creates a Prepared Statement Query using variable arguments for a custom search, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * if the query has no arguments or values the query remains &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * the same and no search params are added, this allows to make a custom &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * search without having to add a lot of if-else statements &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @param baseQuery a database query that contains no search parameters&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @param queryParams search parameters which are pairs that contain criteria and values&amp;amp;#8203;&amp;amp;#8203;, which are added to the database query to generate a ready to run PreparedStatement&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @param connection connection to the database open and ready for querys&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @return returns a PreparedStatement with variable search parameters to get data ready to run&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;public&lt;/span&gt; PreparedStatement &lt;span style="color: rgb(0, 0, 255);"&gt;setQueryParams&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;String baseQuery&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; TreeMap&lt;span style="color: rgb(102, 102, 102);"&gt;&amp;lt;&lt;/span&gt;String&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; Object&lt;span style="color: rgb(102, 102, 102);"&gt;&amp;gt;&lt;/span&gt; queryParams&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt;&lt;br /&gt;        Connection connection&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;throws&lt;/span&gt; SQLException &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;    StringBuilder query &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;new&lt;/span&gt; StringBuilder&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;baseQuery&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;    PreparedStatement preparedStatement &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;    &lt;br /&gt;    Object&lt;span style="color: rgb(102, 102, 102);"&gt;[]&lt;/span&gt; keysObject &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; queryParams&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;keySet&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;().&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;toArray&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*we check the parameters size and if the hashmap is not empty we begin &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;        to build a query using the keys for storing the values */&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;queryParams&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;size&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;()&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;0)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;    &lt;br /&gt;        &lt;span style="color: rgb(176, 0, 64);"&gt;boolean&lt;/span&gt; first &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;true&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;Object key &lt;span style="color: rgb(102, 102, 102);"&gt;:&lt;/span&gt; keysObject&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;first&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*if this is the first value we add the clause "where" &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                     and set first to false so we can add the "and" clauses*/&lt;/span&gt;&lt;br /&gt;                query&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;append&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;" where "&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                first &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;false&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                query&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;append&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;" and "&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;            query&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;append&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;String&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; key &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;" = ? "&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*we create a prepared statement ready for accepting parameters*/&lt;/span&gt;&lt;br /&gt;    preparedStatement &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; connection&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;prepareStatement&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;query&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;toString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;());&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*here we iterate through the values in the set and put the corresponding &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;         values for each one of them in the prepared statement and add them as a &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;         correct Object , the corresponding values equals the current keyset &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;         order since the treemap uses the same order for the keys*/&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;for&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(176, 0, 64);"&gt;int&lt;/span&gt; i &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;0;&lt;/span&gt; i &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;lt;&lt;/span&gt; keysObject&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;length&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt; i&lt;span style="color: rgb(102, 102, 102);"&gt;++)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;        String key &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;String&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; keysObject&lt;span style="color: rgb(102, 102, 102);"&gt;[&lt;/span&gt;i&lt;span style="color: rgb(102, 102, 102);"&gt;];&lt;/span&gt;&lt;br /&gt;        Object value &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; queryParams&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;key&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;value &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;instanceof&lt;/span&gt; Integer&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;            preparedStatement&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setInt&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;i &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;1,&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;Integer&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; value&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;value &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;instanceof&lt;/span&gt; Float&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;            preparedStatement&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setFloat&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;i &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;1,&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;Float&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; value&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;value &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;instanceof&lt;/span&gt; Double&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;            preparedStatement&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setDouble&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;i &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;1,&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;Double&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; value&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;value &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;instanceof&lt;/span&gt; String&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;            preparedStatement&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;i &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;1,&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;String&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; value&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;value &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;instanceof&lt;/span&gt; Date&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(176, 0, 64);"&gt;long&lt;/span&gt; time &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;((&lt;/span&gt;Date&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; value&lt;span style="color: rgb(102, 102, 102);"&gt;).&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getTime&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;            preparedStatement&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setDate&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;i &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;1,&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;new&lt;/span&gt; java&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;sql&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;Date&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;time&lt;span style="color: rgb(102, 102, 102);"&gt;));&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*finally we return the prepared statement with all values set*/&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;return&lt;/span&gt; preparedStatement&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-7593644383489709559?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/7593644383489709559/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=7593644383489709559' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/7593644383489709559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/7593644383489709559'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2011/05/querys-dinamicos.html' title='Query&apos;s dinamicos.'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-2685236454419182810</id><published>2011-05-03T19:37:00.000-07:00</published><updated>2011-05-05T09:38:47.883-07:00</updated><title type='text'>como no debe hacerse un query.</title><content type='html'>&lt;p style="font-family: arial; color: rgb(0, 0, 0);"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;En esta ocasión podemos analizar otra pieza de código la cual requiere un análisis para determinar los problemas que ocasiona programar de esta manera. este es otro ejemplo de código el cual tiene practicas que impiden que la velocidad de ejecución sea óptima.&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="width: 530px; height: 500px; overflow: auto;"&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * Fills the PreparedStatement with its respective values&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @param pstmt&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @param request&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @return&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;public&lt;/span&gt; PreparedStatement &lt;span style="color: rgb(0, 0, 255);"&gt;setQueryvalues&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;PreparedStatement pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; HttpServletRequest request&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;       String search &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"search"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;?&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"search"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;:&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;       log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"search = "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; search&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;            //Check if there is any filter to search&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;search&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"search"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;           String lang &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"lang"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;==&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;?&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;:&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"lang"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           String pid &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"id"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;==&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;?&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;:&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"id"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           String pname &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"name"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;==&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;?&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;:&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"name"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"lang --&amp;gt; "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; lang&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"pid --&amp;gt; "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; pid&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"name --&amp;gt; "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; pname&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"id"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; pid&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"name"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; pname&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"search"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; search&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;pid &lt;span style="color: rgb(102, 102, 102);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!&lt;/span&gt;pid&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;               pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(1,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; pid&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;               pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(1,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; pid&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;pname &lt;span style="color: rgb(102, 102, 102);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!&lt;/span&gt;pname&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;               &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;lang&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                   pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(2,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; pname&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;toUpperCase&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;()&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                   &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                        en este caso la cadena lang viene con el valor %, y el query viene más o menos así:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                        select * from tabla where valor1 like ? and valor2 like ? and valor3 like ?&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                        pero que pasa si al parametro le pasamos un wildcard "%"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                        este queda así:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                        select * from tabla where valor1 like 'valor1' and valor2 like 'valor2' and valor3 like '%'&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                        lo cual forza al query a regresar todos los valores haciendo una comparación tanto inútil,&lt;br /&gt;                   esto sobrecarga la base de datos y evita que se optimizen los tiempos de busqueda&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                        el mismo resultado puede lograrse con:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                        select * from tabla where valor1 like 'valor1' and valor2 like 'valor2'&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                        permitiendo que la base de datos busque solo con los criterios de búsqueda necesarios&lt;br /&gt;                   evitando así una sobrecarga.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                         */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                   pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(3,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;               &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                   pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(2,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                   pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(3,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; pname&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;toUpperCase&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;()&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;               &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;               pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(2,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;               pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(3,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;           &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                en este caso tenemos mas problemas al hacer que todos los parámetros&lt;br /&gt;           de búsqueda sean wildcards, esto hace una búsqueda con like por toda la&lt;br /&gt;            tabla y si el query trae un join esto alenta los resultados&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;                 */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;           pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(1,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(2,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(3,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"%"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;Exception e&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;            este antipatron ha sido explicado anteriormente como ocultamiento de excepciones,&lt;br /&gt;       este impide depurar correctamente el código para poder encontrar una excepción caso de ocurrir.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;             */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       e&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;return&lt;/span&gt; pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-2685236454419182810?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/2685236454419182810/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=2685236454419182810' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/2685236454419182810'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/2685236454419182810'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2011/05/como-no-debe-hacerse-un-query.html' title='como no debe hacerse un query.'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-8502832345082810555</id><published>2011-04-30T10:52:00.000-07:00</published><updated>2011-05-05T09:15:43.842-07:00</updated><title type='text'>malas practicas del codigo</title><content type='html'>&lt;pre&gt;&lt;span style="color: rgb(0, 0, 0); font-style: italic;font-family:arial;" &gt;&lt;span style="font-size:100%;"&gt;Malas Practicas de Código&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;esta es la segunda entrada, en esta analizaremos de nueva cuenta código&lt;br /&gt;con malas practicas y que puede ser mejorado, recuerda que las buenas&lt;br /&gt;practicas de programación  mejoran la calidad del programa y disminuyen&lt;br /&gt;el tiempo correcciones&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="width: 520px; height: 500px; overflow: auto;"&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*Hay que ser mas descriptivo cuando se genera un JavaDoc, recuerda que eso ayuda al momento de la documentaciel sistema.*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/**&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * Generates the paginated list&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @param query&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @param numPagina&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @param numRegPagina&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @param hmPaging&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @param request&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     * @return&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;     */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*Los nombres de los parametros son espaingles, lo mejor es ser&lt;br /&gt;coherente y manejar todo en un solo idioma.*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;public&lt;/span&gt; ArrayList &lt;span style="color: rgb(0, 0, 255);"&gt;getPagedList&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;String query&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(176, 0, 64);"&gt;int&lt;/span&gt; numPagina&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(176, 0, 64);"&gt;int&lt;/span&gt; numRegPagina&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; HashMap hmPaging&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; HttpServletRequest request&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;   ArrayList list &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;new&lt;/span&gt; ArrayList&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;   ResultSet rs &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;openConecction&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;       PreparedStatement pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;       pstmt &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; con&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;prepareStatement&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;query&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; ResultSet&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;TYPE_SCROLL_INSENSITIVE&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; ResultSet&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;CONCUR_READ_ONLY&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*No es Correcto usar Scroll Insensitive como&lt;br /&gt;        Propiedad para generar un ResultSet,Esto Consume mas memoria,&lt;br /&gt;        y en un sistema Web la cantidad de Memoria consumida es&lt;br /&gt;        Crucial para el buen funcionamiento*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       pstmt &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; setQueryvalues&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;       pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setFetchSize&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;numRegPagina&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;       rs &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; pstmt&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;executeQuery&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(176, 0, 64);"&gt;int&lt;/span&gt; cont &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;1;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(176, 0, 64);"&gt;int&lt;/span&gt; fila &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; numRegPagina &lt;span style="color: rgb(102, 102, 102);"&gt;*&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;numPagina &lt;span style="color: rgb(102, 102, 102);"&gt;-&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;1)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;1;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;absolute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;fila&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; numRegPagina &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&lt;/span&gt; gt&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(102, 102, 102);"&gt;0)&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;           &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*no es correcto hacer que el ResultSet vaya al numero absoluto,&lt;br /&gt;            esto consume una gran cantidad de memoria.*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;           &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;do&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;               Asset asset &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;new&lt;/span&gt; Asset&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;               asset&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setId&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;new&lt;/span&gt; Integer&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getInt&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;arrayAsset&lt;span style="color: rgb(102, 102, 102);"&gt;[0])));&lt;/span&gt;&lt;br /&gt;               asset&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setId_division&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;new&lt;/span&gt; Integer&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;arrayAsset&lt;span style="color: rgb(102, 102, 102);"&gt;[1])));&lt;/span&gt;&lt;br /&gt;               asset&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setName_sp&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;arrayAsset&lt;span style="color: rgb(102, 102, 102);"&gt;[2]));&lt;/span&gt;&lt;br /&gt;               asset&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setName_en&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;arrayAsset&lt;span style="color: rgb(102, 102, 102);"&gt;[3]));&lt;/span&gt;&lt;br /&gt;               asset&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setStatus&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;new&lt;/span&gt; Integer&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;arrayAsset&lt;span style="color: rgb(102, 102, 102);"&gt;[4])));&lt;/span&gt;&lt;br /&gt;               asset&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setUpdated&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;arrayAsset&lt;span style="color: rgb(102, 102, 102);"&gt;[5]));&lt;/span&gt;&lt;br /&gt;               asset&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setImage&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;arrayAsset&lt;span style="color: rgb(102, 102, 102);"&gt;[6]));&lt;/span&gt;&lt;br /&gt;               asset&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setId_assetType&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;new&lt;/span&gt; Integer&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;arrayAsset&lt;span style="color: rgb(102, 102, 102);"&gt;[7])));&lt;/span&gt;&lt;br /&gt;               list&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;add&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;asset&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;               cont&lt;span style="color: rgb(102, 102, 102);"&gt;++;&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;while&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;next&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;()&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;cont &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&lt;/span&gt; lt&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt;  numRegPagina&lt;br /&gt;  &lt;br /&gt;           &lt;span style="color: rgb(102, 102, 102);"&gt;));&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; Integer reccordCount &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;new&lt;/span&gt; Integer&lt;span style="color: rgb(102, 102, 102);"&gt;(0);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/* El last va al ultimo registro, esto consume una gran cantidad de tiempo y memoria,&lt;br /&gt;         lo mejor es siempre dejar que este trabajo sea por parte de la base de datos,&lt;br /&gt;         haciendo un segundo query con un count a la base de datos se disminuye este problema */&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;last&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;())&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;           reccordCount &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;new&lt;/span&gt; Integer&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;rs&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getRow&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;());&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;       log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"reccordCount --&amp;gt; "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; reccordCount&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;       hmPaging&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;put&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"reccount"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; reccordCount&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*Jamas dejen un try y catch sin escalarlo correctamente este&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;        tipo de practica es conocida como &lt;a href="http://en.wikipedia.org/wiki/Error_hiding" target="_new"&gt;ocultamiento de errores&lt;/a&gt; ,&lt;br /&gt;    lo mejor es escalar la excepción mostrar los detalles y separar las excepciones,&lt;br /&gt;    para determinar si fue error del usuario o del programador */&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;Exception e&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;       e&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;finally&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;this&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;closeConnection&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;list&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-8502832345082810555?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/8502832345082810555/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=8502832345082810555' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/8502832345082810555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/8502832345082810555'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2011/04/malas-practicas-del-codigo.html' title='malas practicas del codigo'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-1196735583712274705</id><published>2011-04-16T12:57:00.000-07:00</published><updated>2011-05-09T08:45:48.297-07:00</updated><title type='text'>Malas Practicas Java (2)</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(0, 195, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-size:100%;" &gt;este codigo se llama reemplazaCadena, sin embargo java tiene una utilidad de código el cual es: &lt;a href="http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#replace%28char,%20char%29" target="_new"&gt;replace&lt;/a&gt; y &lt;a href="http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#replaceAll%28java.lang.String,%20java.lang.String%29" target="_new"&gt;replaceAll&lt;/a&gt;, la cual viene como parte de la especificación java&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 195, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;div  style="width: 520px; height: 400px; overflow: auto;color:black;"&gt;&lt;br /&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;static&lt;/span&gt; String &lt;span style="color: rgb(0, 0, 255);"&gt;reemplazaCadena&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;String texto&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; String patron&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt;&lt;br /&gt;           String nuvo_patron&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(176, 0, 64);"&gt;int&lt;/span&gt; posicion_del_ultimo_patron &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;0,&lt;/span&gt; posicion_de_un_nuevo_patron &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;0;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(176, 0, 64);"&gt;int&lt;/span&gt; longitud_del_patron &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; patron&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;length&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;       StringBuffer result &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;new&lt;/span&gt; StringBuffer&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;texto &lt;span style="color: rgb(102, 102, 102);"&gt;==&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;||&lt;/span&gt; texto&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;||&lt;/span&gt; patron &lt;span style="color: rgb(102, 102, 102);"&gt;==&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;||&lt;/span&gt; patron&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;||&lt;/span&gt; nuvo_patron &lt;span style="color: rgb(102, 102, 102);"&gt;==&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;           &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;while&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;((&lt;/span&gt;posicion_de_un_nuevo_patron &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; texto&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;indexOf&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;patron&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt;&lt;br /&gt;               posicion_del_ultimo_patron&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;0)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;           result&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;append&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;texto&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;substring&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;posicion_del_ultimo_patron&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt;&lt;br /&gt;                   posicion_de_un_nuevo_patron&lt;span style="color: rgb(102, 102, 102);"&gt;));&lt;/span&gt;&lt;br /&gt;           result&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;append&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;nuvo_patron&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;           posicion_del_ultimo_patron &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; posicion_de_un_nuevo_patron &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; longitud_del_patron&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;       result&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;append&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;texto&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;substring&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;posicion_del_ultimo_patron&lt;span style="color: rgb(102, 102, 102);"&gt;));&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;return&lt;/span&gt; result&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;toString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 195, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 195, 0);"&gt;&lt;span style="color: rgb(0, 195, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:100%;" &gt;Este antipatrón se llama &lt;a href="http://es.wikipedia.org/wiki/Reinventar_la_rueda"&gt;Reinventar la rueda&lt;/a&gt; , un análisis de la documentación puede ahorrar tiempo y eliminar este tipo de problemas a la hora de programar.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 195, 0);"&gt;&lt;span style="font-weight: bold; color: rgb(0, 195, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-1196735583712274705?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/1196735583712274705/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=1196735583712274705' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/1196735583712274705'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/1196735583712274705'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2011/04/malas-practicas-2.html' title='Malas Practicas Java (2)'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-851910369497906087</id><published>2011-04-16T11:09:00.000-07:00</published><updated>2011-05-05T09:35:33.730-07:00</updated><title type='text'>Malas Practicas Java (1)</title><content type='html'>&lt;span class="Apple-tab-span" style="white-space: pre; color: rgb(0, 0, 0);"&gt;MALAS PRACTICAS.&lt;/span&gt;&lt;div style="color: rgb(51, 204, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;ahora vamos a analizar código, el siguiente es un código extraído de un programador de&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;una empresa donde estuve, digamos que este programador se adueño del código que no&lt;br /&gt;era propiedad suya,&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; sin embargo debido a que su orgullo no le permitió preguntar como&lt;br /&gt;era correcto,&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; siempre ocasiono serios problemas, es mejor preguntar cuando uno este en duda,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;o apoyarse de los demas programadores, siempre es mejor perder 2 o 3 minutos que&lt;br /&gt;se traducen en horas ahorradas,&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;la mejor filosofia es:&lt;br /&gt;si pasan mas de 3o minutos y no encuentras una respuesta por ti mismo:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;pregunta...Alguien conocerá la respuesta.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="width: 520px; height: 500px; overflow: auto;"&gt;&lt;br /&gt;&lt;div class="highlight"&gt;&lt;pre&gt; &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*código de struts 1*/&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*si el código es mas de 100 lineas entonces los métodos no están optimizados*/&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;public&lt;/span&gt; ActionForward &lt;span style="color: rgb(0, 0, 255);"&gt;execute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;ActionMapping mapping&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; ActionForm form&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt;&lt;br /&gt;              HttpServletRequest request&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; HttpServletResponse response&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;throws&lt;/span&gt; Exception &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*este tipo de mensajes de log debe de ser removido de la version final, esto solo hace que la aplicaciea mas lenta y por lo tanto su uso no es recomendado */&lt;/span&gt;&lt;br /&gt;          log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"Entra a Asset"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;          HttpSession session &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getSession&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*este busca una session del atributo request y pregunta por el perfil, aquí la referencia deberestar dentro de los filtros de sesi no dentro del co, lo cual hace una mala practica de separacion */&lt;/span&gt;&lt;br /&gt;          Users user &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;Users&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; session&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"activeUser"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;          String usrprofile &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"usrprofile"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;?&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"usrprofile"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;:&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"ADMIN"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(!&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"USRMX"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;usrprofile&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"USRLC"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;usrprofile&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"ADMIN"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;usrprofile&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"USRSL"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;usrprofile&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"MEGAADMIN"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;usrprofile&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;              response&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;sendError&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(425);&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;          String userUpdate &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*los cos de los lenguajes no deben manejarse dentro de la acciestos deben manejarse con el uso de locales*/&lt;/span&gt;&lt;br /&gt;          String lang &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"lang"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;?&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"lang"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;:&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*si los cos if y else no contienen ejecucion alguna entonces&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;            la manera correcta de proceder es por medio de un if y un parametro negado,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;            este tipo de practica hace que el sistema haga mas saltos if-else,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;            lo cual se traduce en impacto al rendimiento */&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;lang&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;lang&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;length&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;()&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;==&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;3&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"_en"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;lang&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;              response&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;sendError&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(425);&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;user &lt;span style="color: rgb(102, 102, 102);"&gt;==&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;              log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"sin sesion"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;lang&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                  response&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;sendError&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(200);&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                  response&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;sendError&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(201);&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Colocacion de variables en request&lt;/span&gt;&lt;br /&gt;          request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"usrprofile"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; usrprofile&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;          request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"lang"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; lang&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;          request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"section"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"admin.lc.catalog.materials.asset"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;          request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"class"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; CLASS_NAME&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;toLowerCase&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;());&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;          String mappingForward &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;          AssetForm assetForm &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;AssetForm&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; form&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Obtiene la url&lt;/span&gt;&lt;br /&gt;          String requestedUrl &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getRequestURL&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;().&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;toString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;          String optionStr &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; requestedUrl&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;substring&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;br /&gt;                  requestedUrl&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;lastIndexOf&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"/"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;1,&lt;/span&gt; requestedUrl&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;lastIndexOf&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"."&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;));&lt;/span&gt;&lt;br /&gt;          log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"opcion Elegida ==&amp;gt; "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; optionStr&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Si es modo administrador&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;requestedUrl&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;indexOf&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"admin"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;0)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Devuelve la lista de resultados&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;optionStr&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"assetList"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                  log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"entro en assetList"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  ArrayList catalogList &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; getAssetList&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;request&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Remueve variables de request&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;removeAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"catalogList"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;removeAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"title"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Coloca variables en request&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"catalogList"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; catalogList&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"title"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"list"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                  mappingForward &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"success"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Muestra el formulario para agregar un asset&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;optionStr&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"assetFormAdd"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                  log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"entro en assetFormAdd"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  ArrayList listAssettype &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; toolDAO&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAssetTypeList&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                  Ccprofile profile &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;Ccprofile&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; session&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"activeProfile"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  String activeProfile &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; profile&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getName&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                  HashMap mapSP &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;HashMap&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getSession&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;().&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"mapSP"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  String pos10 &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;String&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; mapSP&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"POS-10"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  ArrayList listDivision &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;activeProfile&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equalsIgnoreCase&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;pos10&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                      user &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;Users&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; session&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"activeUser"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                      String idDiv &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;String&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; user&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getDivisionId&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;().&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;toString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                      listDivision &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; toolDAO&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getDivisionListByDiv&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;idDiv&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                      listDivision &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; toolDAO&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getDivisionList&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Remueve variables de request&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;removeAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"list_assettype"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;removeAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"list_division"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;removeAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"title"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Coloca variables en request&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"list_assettype"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; listAssettype&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"list_division"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; listDivision&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"title"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"formAdd"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  mappingForward &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"success"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Muestra el formulario con los datos para editar un registro&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;optionStr&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"assetFormEdit"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                  log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"entro en assetFormEdit"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  ArrayList listAssettype &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; toolDAO&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAssetTypeList&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                  Ccprofile profile &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;Ccprofile&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; session&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"activeProfile"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  String activeProfile &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; profile&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getName&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                  HashMap mapSP &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;HashMap&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getSession&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;().&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"mapSP"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  String pos10 &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;String&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; mapSP&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;get&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"POS-10"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  ArrayList listDivision &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;activeProfile&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equalsIgnoreCase&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;pos10&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                      user &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;Users&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; session&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"activeUser"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                      String idDiv &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;String&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; user&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getDivisionId&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;().&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;toString&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                      listDivision &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; toolDAO&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getDivisionListByDiv&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;idDiv&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                      listDivision &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; toolDAO&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getDivisionList&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"list_assettype"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; listAssettype&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"list_division"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; listDivision&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                  String id &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"id"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;id &lt;span style="color: rgb(102, 102, 102);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!&lt;/span&gt;id&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                      Asset asset &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; getAssetById&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;request&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                      request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"asset"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; asset&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Remueve variables de request&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;removeAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"title"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Coloca variables en request&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"title"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"formEdit"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  mappingForward &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"success"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Agrega un registro a la tabla de asset&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;optionStr&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"assetAdd"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                  log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"entro en assetAdd: "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; assetForm&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"Nombre esp: "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; assetForm&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getName_sp&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;());&lt;/span&gt;&lt;br /&gt;                  String res &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;                  PrintWriter writer &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; response&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getWriter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*el uso del metodo getfechaActualHoraActual no sigue la notaciamel-case correcta*/&lt;/span&gt;&lt;br /&gt;                  userUpdate &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; user&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAccount&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;()&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;" "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; Utils&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getfechaActualHoraActual&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                  log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"usuario ---&amp;gt; "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; userUpdate&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  assetForm&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setUpdated&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;userUpdate&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// valida que no este duplicado el registro&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*estas validaciones van en el ActionForm y no en el Action*/&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(!&lt;/span&gt;isDuplicated&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;assetForm&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                      request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"title"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"add"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Agrega el registro&lt;/span&gt;&lt;br /&gt;                      res &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; addReccord&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;assetForm&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                      writer&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;print&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"ok"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                      writer&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;flush&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                      writer&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;close&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                      request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;removeAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"title"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                      request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"title"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"formAdd"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                      writer&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;print&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"duplicated"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// res = "duplicatedRecord";&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;                  mappingForward &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; res&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Actualiza el registro en la base de datos&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;optionStr&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"assetEdit"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                  log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"entro en assetEdit: "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; assetForm&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  userUpdate &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; user&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAccount&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;()&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;" "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; Utils&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getfechaActualHoraActual&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                  log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"usuario ---&amp;gt; "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; userUpdate&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  assetForm&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setUpdated&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;userUpdate&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  String update &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; updateAsset&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;assetForm&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"title"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"edit"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;update&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"success"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                      PrintWriter writer &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; response&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getWriter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                      writer&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;print&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"ok"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                      writer&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;flush&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                      writer&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;close&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;();&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;                  mappingForward &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"success"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Elimina un registro en la base de datos.&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;optionStr&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"assetDelete"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*Este flujo if-else no ejecuta nada*/&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getHeader&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"Referer"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                      &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getHeader&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"Referer"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;).&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;toUpperCase&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;().&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;indexOf&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"KO.COM"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;-1&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;||&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getHeader&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"Referer"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;).&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;toUpperCase&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;().&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;indexOf&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"8888"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;-1)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                          System&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;out&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;println&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"referer ==&amp;gt; "&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;+&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getHeader&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"Referer"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;));&lt;/span&gt;&lt;br /&gt;                          String token &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"nekoTlaiceps"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                          &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*estos comentarios son indescriptivos y no se recomiendan, la recomendacion es que se indique que valores puede traer la variable y como debe ser tratada cada una de ellas*/&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// valida que el token traiga algo&lt;/span&gt;&lt;br /&gt;                          &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;token &lt;span style="color: rgb(102, 102, 102);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!&lt;/span&gt;token&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equalsIgnoreCase&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// obtiene el hdiv de session&lt;/span&gt;&lt;br /&gt;                              String hdiv &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;String&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; session&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"HDIV"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// valida que el token sea igual al hdiv de session&lt;/span&gt;&lt;br /&gt;                              &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;hdiv&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equalsIgnoreCase&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;token&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                                  log&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;debug&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"entro en assetDelete"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                                  String id &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;getParameter&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"id"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                                  &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;id &lt;span style="color: rgb(102, 102, 102);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;null&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;!&lt;/span&gt;id&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                                      &lt;span style="color: rgb(176, 0, 64);"&gt;boolean&lt;/span&gt; update &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; deleteAsset&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;request&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                                      request&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;setAttribute&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"title"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;,&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"edit"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                                      &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;update&lt;span style="color: rgb(102, 102, 102);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                                          mappingForward &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"success"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;                                      &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                                          mappingForward &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"error"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;                                      &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;                                  &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;                              &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                                  mappingForward &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"error"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;                              &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;                          &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                              mappingForward &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;"error"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;                          &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;                          token &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(186, 33, 33);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;;&lt;/span&gt;&lt;br /&gt;                      &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                          System&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;out&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;println&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"Error referer no contiene token"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                          response&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;sendError&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(425);&lt;/span&gt;&lt;br /&gt;                      &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;                      System&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;out&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;println&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"Referer es null "&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;                      response&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;sendError&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(425);&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;else&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt; &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;// Si es modo usuario&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(64, 128, 128); font-style: italic;"&gt;/*este código es innecesario, debido a que no ejecuta ninguna sentencia*/&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;optionStr&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;equals&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(186, 33, 33);"&gt;"News"&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;))&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;{&lt;/span&gt;&lt;br /&gt;              &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;          &lt;span style="color: rgb(0, 128, 0); font-weight: bold;"&gt;return&lt;/span&gt; mapping&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(125, 144, 41);"&gt;findForward&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;(&lt;/span&gt;mappingForward&lt;span style="color: rgb(102, 102, 102);"&gt;);&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(102, 102, 102);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: rgb(51, 204, 0);"&gt;&lt;span class="Apple-tab-span"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: rgb(51, 204, 0);"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;como pueden ver, la acción debió dividirse en varias acciones, permitiendo que los códigos sean mas faciles de entender, esta es una sola acción que pretende meter todo en uno, este tipo de antipatrones se llama God Object.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-851910369497906087?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/851910369497906087/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=851910369497906087' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/851910369497906087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/851910369497906087'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2011/04/malas-practicas.html' title='Malas Practicas Java (1)'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-4693140661519304499</id><published>2010-04-23T21:32:00.000-07:00</published><updated>2010-05-24T07:28:43.335-07:00</updated><title type='text'></title><content type='html'>hoy he decidido hablar algo acerca de los sistemas cerrados, recientemente me encontre con genexus un generador de codigo, hecho en uruguay, por si sola la herramienta promete bastante, con capacidades de generar codigo java, codigo de .net, y otros lenguajes, despues de analizar todo, he encontrado varias cosas que no me gustaron.&lt;br /&gt;&lt;br /&gt;1.- la herramienta cuesta mucho, aproximadamente 30,000 pesos por año, este tipo de licencias son demasiado caras lo cual hace que conseguirlas sea algo completamente fuera del presupuesto de algunas personas.&lt;br /&gt;&lt;br /&gt;2.- el codigo por fuera esta encriptado, requiere el ide necesariamente para hacer modificaciones, no es posible abrirlo con un editor de texto.&lt;br /&gt;&lt;br /&gt;3.- cuando se requiere abrir un archivo, ej: csv, con un millon de registros o alguna cantidad exagerada, el sistema se come la memoria. esto puede llegar a pasar, no es del todo comun pero pasa.&lt;br /&gt;&lt;br /&gt;4.- no hay libros en la red, la pagina, principal de ayuda da poca información de los temas, el sistema esta cerrado, no es como el resto de los lenguajes que sacan información y libros en todos lados.&lt;br /&gt;&lt;br /&gt;5.- el sistema en si solo funciona en windows, requiere sql server 2005 o 2008, para el proyecto, ademas .net, de manera que si alguien quiere probar en otra plataforma el desarrollo, tiene que tener windows a fuerzas para generar el codigo.&lt;br /&gt;&lt;br /&gt;6.- las librerias de el sistema son antiguas, de manera que si ponen alguna libreria nueva con un codigo que se quito porque ha sido sustituido por una version mejor, este deja de servir, esto me paso con las librerias del poi 3.6.&lt;br /&gt;&lt;br /&gt;7.- el sistema en si puede dejarte hacer codigo basura y decirte que esta bien, pero a la hora de generar codigo es cuando truena al intentar asignar objetos de un tipo distinto, cosa que no pasa cuando uno hace que funcione todo en el lenguaje que se genero.&lt;br /&gt;&lt;br /&gt;8.- el servidor de versionamiento es aun rudimentario, permite subir basura y para resolver conflictos es bastante tedioso, seria mejor usar una herramienta de versionamiento como svn.&lt;br /&gt;&lt;br /&gt;estas son todas las cosas que tengo que decir de dicha herramienta, la verdad, me quede esperando más, quisiera que fuera mas simple decirlo, pero creo que tengo muchos puntos en contra, prefiero tener el control de mi lenguaje de preferencia, sea el que sea, a intentar juntar todo en un todo en uno que no es maestro en nada.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-4693140661519304499?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/4693140661519304499/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=4693140661519304499' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/4693140661519304499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/4693140661519304499'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2010/04/hoy-he-decidido-hablar-algo-acerca-de.html' title=''/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-7658043266755568306</id><published>2010-02-12T13:36:00.000-08:00</published><updated>2010-02-12T13:44:05.606-08:00</updated><title type='text'></title><content type='html'>bueno buscando algo de renderizar imagenes o ver como hacer imagenes dinamicas al vuelo encontre esto:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.nihilogic.dk/labs/canvas3d/" target="_new"&gt;&lt;br /&gt;http://www.nihilogic.dk/labs/canvas3d/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;se me hizo interesante ver el manejo del canvas del html5 usado para generar modelos 3d en base a modelos simples cargados de manera dinamica.&lt;br /&gt;&lt;br /&gt;estos modelos se cargan usando json.&lt;br /&gt;&lt;br /&gt;seguire investigando mientras generación de modelos en base a canvas&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-7658043266755568306?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/7658043266755568306/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=7658043266755568306' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/7658043266755568306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/7658043266755568306'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2010/02/bueno-buscando-algo-de-renderizar.html' title=''/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-864005380703919571</id><published>2010-01-24T22:55:00.000-08:00</published><updated>2010-01-24T23:05:21.705-08:00</updated><title type='text'>recuperacion de información</title><content type='html'>bueno de seguro que les ha pasado alguna vez eso de perder información de un disco duro, es algo completamente espantoso y critico, cuando eso pasa uno puede llamar a alguien que recupere la información o recuperarla por si mismo, en este caso he preferido hacerlo yo mismo, debido a que en uno de mis post's anteriores critique a unos tipos que chantajeaban con borrar la info de los discos duros.&lt;br /&gt;&lt;br /&gt;en fin para eso uso el software de ontrack easy recovery pro, que en lo particular me ha funcionado de maravilla, logre recuperar mi info antes de que terminara el fin de semana, y lo he logrado, recupere todos mis codigos fuente antes de que se perdieran en el olvido.&lt;br /&gt;&lt;br /&gt;bueno les recomiendo mucho la herramienta&lt;br /&gt;&lt;a href="http://www.ontrackdatarecovery.es/software-recuperacion-ficheros/" target="_new"&gt;&lt;br /&gt;http://www.ontrackdatarecovery.es/software-recuperacion-ficheros/&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;bueno eso si, es caro el software pero creo que lo vale, total la informacion es muy preciada, y mas si no quieres que algun desconocido tome datos personales tuyos.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-864005380703919571?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/864005380703919571/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=864005380703919571' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/864005380703919571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/864005380703919571'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2010/01/recuperacion-de-informacion.html' title='recuperacion de información'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-7891886877752817091</id><published>2010-01-07T14:32:00.000-08:00</published><updated>2010-01-07T14:37:40.477-08:00</updated><title type='text'>borrar mi existencia de facebook.</title><content type='html'>bueno en esta ocasión decidí borrar todas mis cuentas como hi5 o facebook, me doy cuenta de que no las necesite nunca, solo eran desperdicio de tiempo, intente usar la maquina del suicidio para eliminar facebook pero no funciono, tienen bloqueada la ip, así que decidí hacerlo todo manualmente, el resultado... no mas facebook o mas hi5, bueno comenzando el año hay que deshacerse de todo lo que uno no necesita, así que continua mi jornada sin mas cosas que extrañe, :)&lt;br /&gt;&lt;br /&gt;claro para todo esto tengo mejores expectativas, twitter y demás redes son la cosa de hoy en dia, prefiero usarlas, son mas interesantes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-7891886877752817091?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/7891886877752817091/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=7891886877752817091' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/7891886877752817091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/7891886877752817091'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2010/01/bueno-en-esta-ocasion-decidi-borrar.html' title='borrar mi existencia de facebook.'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-5895452460667583308</id><published>2010-01-01T21:21:00.000-08:00</published><updated>2010-01-01T21:36:32.035-08:00</updated><title type='text'>entrada al 2010</title><content type='html'>&lt;p&gt;&lt;br /&gt;bueno esta es mi primera entrada del 2010, espero que se haga mas regularmente, bueno este año estuve haciendo varios proyectos personales y deje mis 2 trabajos anteriores, la razón, creo que necesitaba espacio para terminar mis compromisos personales, obtener mi titulo, y dedicarme mas a investigación de nuevos métodos de desarrollo.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Deje de usar windows, ahora uso mas linux, para que no se vea nada feo le metí un tema tipo mac, me deja hasta los botones tipo mac, me dedico mas a la maquetación ahora, no soy tan bueno pero confío en que la practica me hará mejor como siempre, estoy dedicado a desarrollo web, un poco de j2me y algo de webservices, bueno espero poder conseguir mis metas este año como son:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt; &lt;li&gt;Pulir el mi ORM hecho en java&lt;/li&gt;&lt;br /&gt; &lt;li&gt;Desarrollar más codigos en QT4&lt;/li&gt;&lt;br /&gt; &lt;li&gt;Crear Otro Proyecto para &lt;a href="http://sourceforge.net/"&gt;http://sourceforge.net/&lt;/a&gt;   &lt;/li&gt;&lt;br /&gt; &lt;li&gt;Aprender el lenguaje GO de Google &lt;a href="http://golang.org/" &gt;http://golang.org/&lt;/a&gt; &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt; entre estas cosas quiero tambi&amp;eacute;n mejorar algunas cosas de este blog que est&amp;aacute;n algo sencillas, y entre esas aprender portugu&amp;eacute;s , bueno son algunos de mis prop&amp;oacute;sitos de año nuevo, comenzando desde hoy comenzare a apartar mas tiempo para bloggear. :)&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-5895452460667583308?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/5895452460667583308/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=5895452460667583308' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/5895452460667583308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/5895452460667583308'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2010/01/entrada-al-2010.html' title='entrada al 2010'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-4473470320448726161</id><published>2009-10-26T21:23:00.000-07:00</published><updated>2009-12-03T00:38:12.617-08:00</updated><title type='text'></title><content type='html'>bueno haciendo algo de scripting de paginado, me di cuenta de que habia una forma de hacer que conserve todos los parametros y agregar solo los de numero de pagina para poder conservar una busqueda, este es el script generado, como pueden ver es muy sencillo&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#macro( paginado  )&lt;br /&gt;#if($totalPages)&lt;br /&gt;#if( $totalPages &gt; 0 )&lt;br /&gt;  #foreach ($page in [1..$totalPages])&lt;br /&gt;    &amp;lt;a href="$link.addIgnore('pageNum').addAllParameters().addQueryData('pageNum',$page)"&lt;br /&gt;&amp;gt;&lt;br /&gt;$page&lt;br /&gt;&amp;lt;/a&amp;gt;&lt;br /&gt;  #end&lt;br /&gt;#end&lt;br /&gt;#end&lt;br /&gt;#end&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-4473470320448726161?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/4473470320448726161/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=4473470320448726161' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/4473470320448726161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/4473470320448726161'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/10/bueno-haciendo-algo-de-scripting-de.html' title=''/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-3829581349526801438</id><published>2009-10-05T08:34:00.000-07:00</published><updated>2009-10-05T09:08:07.781-07:00</updated><title type='text'>conectando midlets por recordstore</title><content type='html'>ultimamente he vuelto a trabajar j2me para desarrollar aplicaciones para moviles, esta vez voy a intentar algo que es en cierta forma algo no muy estandar, me refiero a hacer que 2 midlets se comuniquen entre si, para eso requerimos como paso inicial 2 midlets, recordstores, el primer paso es crear un midlet con la siguiente estructura para poder iniciar, este es el midlet de escucha, este podria ser un miniservidor, para eso el midlet requiere como codigo inicial:&lt;br /&gt;&lt;br /&gt;protected void startApp() throws MIDletStateChangeException {&lt;br /&gt; try {&lt;br /&gt;//abrimos un recordstore con permisos de escritura de cualquier otro midlet&lt;br /&gt;  RecordStore rms = RecordStore.openRecordStore("owner", true,      RecordStore.AUTHMODE_ANY ,true );&lt;br /&gt;//agregamos un record listener generado por nosotros&lt;br /&gt;     rms.addRecordListener( new ListenerRMS() );&lt;br /&gt;   Display d = Display.getDisplay(this);&lt;br /&gt;  d.setCurrent(null);&lt;br /&gt; } catch (RecordStoreFullException e) {&lt;br /&gt;  e.printStackTrace();&lt;br /&gt; } catch (RecordStoreNotFoundException e) {&lt;br /&gt;  e.printStackTrace();&lt;br /&gt; } catch (RecordStoreException e) {&lt;br /&gt;  e.printStackTrace();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;este requiere una clase que implemente el codigo del recordlistener esto podria ser algo como esto:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class ListenerRMS implements RecordListener {&lt;br /&gt;&lt;br /&gt;  public void recordAdded(RecordStore recordStore, int recordId) {&lt;br /&gt;      try {&lt;br /&gt;          byte[] data = recordStore.getRecord(recordId);&lt;br /&gt;          String rmsToCreate = new String( data );&lt;br /&gt;          System.out.println( "datos: " + rmsToCreate );&lt;br /&gt;      } catch (RecordStoreNotOpenException e) {&lt;br /&gt;          System.err.println( e.toString() );&lt;br /&gt;      } catch (InvalidRecordIDException e) {&lt;br /&gt;          System.err.println( e.toString() );&lt;br /&gt;      } catch (RecordStoreException e) {&lt;br /&gt;          System.err.println( e.toString() );&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;este codigo permite generar un pequeño server con listener como un rms&lt;br /&gt;&lt;br /&gt;y este codigo del lado del otro midlet permite escribir en un recordstore compartido, con el vendor especificado, de manera que cuando agregues valores al record, el listener del otro midlet podra leer los datos generados desde otro midlet y ejecutar codigo&lt;br /&gt;&lt;br /&gt;rms = RecordStore.openRecordStore("owner", "vendor","owner" );&lt;br /&gt;          byte[] data = "texto de prueba".getBytes();&lt;br /&gt;          rms.addRecord(data, 0, data.length);&lt;br /&gt;&lt;br /&gt;para esto tienes primero que correr el midlet 1 y despues el midlet 2 y ejecutar un codigo que escriba en el otro recordstore. bueno esto aumenta el numero de posibilidades a la hora de conectar 2 midlets, sin embargo no todos los telefonos soportan esta caracteristica.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-3829581349526801438?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/3829581349526801438/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=3829581349526801438' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/3829581349526801438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/3829581349526801438'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/10/conectando-midlets-por-recordstore.html' title='conectando midlets por recordstore'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-2477813946545347043</id><published>2009-07-14T07:02:00.000-07:00</published><updated>2009-07-14T07:22:50.679-07:00</updated><title type='text'></title><content type='html'>&lt;p&gt;&lt;br /&gt;bueno en esta ocasion se subio el nuevo buscador de objetos para generar querys dinamicos, esta vez tiene soporte para transacciones con objetos :&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;search.addBatchObject(book1);&lt;br /&gt;search.addBatchObject(book2);&lt;br /&gt;search.addBatchObject(book3);&lt;br /&gt;search.executeBatch();&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;a href="http://sourceforge.net/projects/dinamicquerygen/" target="_blank"&gt;h&lt;/a&gt;&lt;a href="http://sourceforge.net/projects/dinamicquerygen/" target="_blank"&gt;ttp://sourceforge.net/projects/dinamicquerygen/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;y tambien corrige algunos bugs y contiene algunos ejemplos de uso, y proximamente estara agregando mas sentencias.&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-2477813946545347043?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/2477813946545347043/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=2477813946545347043' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/2477813946545347043'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/2477813946545347043'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/07/bueno-en-esta-ocasion-se-subio-el-nuevo.html' title=''/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-3374003040827407409</id><published>2009-06-03T09:35:00.000-07:00</published><updated>2009-06-03T09:38:28.136-07:00</updated><title type='text'></title><content type='html'>hola de nuevo acabo de subir mi nuevo release del buscador de objetos, este corrige algunos bugs de seguridad anteriores, este permite subir correctamente las llaves primarias al momento de insercion, bueno un fix rapido, despues subo los demas archivos, mientras les dejo el link para que lo vean.&lt;br /&gt;&lt;br /&gt;&lt;a href="https://sourceforge.net/project/showfiles.php?group_id=250622&amp;amp;package_id=317069&amp;amp;release_id=687070" target="_blank"&gt;https://sourceforge.net/project/showfiles.php?group_id=250622&amp;amp;package_id=317069&amp;amp;release_id=687070&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;bueno que tengan una buena semana, nos vemos.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-3374003040827407409?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/3374003040827407409/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=3374003040827407409' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/3374003040827407409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/3374003040827407409'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/06/hola-de-nuevo-acabo-de-subir-mi-nuevo.html' title=''/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-1109357401873557334</id><published>2009-05-30T08:16:00.000-07:00</published><updated>2009-05-30T08:31:19.238-07:00</updated><title type='text'>correcciones del sistema</title><content type='html'>hola a todos, esta vez he estado checando el sistema de busqueda de objetos y parece que tiene unos pequeños bugs a la hora de insertar, estare arreglando esto, espero que no me tome tiempo, pero apenas este listo saco la ultima actualizacion en linea. bueno como siempre esten pendientes de los cambios y mientras estoy haciendo unas actualizaciones en el corporativo de coca.&lt;br /&gt;&lt;br /&gt;la pagina es:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.coca-colamexico.com.mx/"&gt;http://www.coca-colamexico.com.mx/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;por mientras estoy basandome en los estandares css para hacer la transicion correcta. para mas informacion les recomiendo el siguiente libro.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.amazon.com/Pro-CSS-HTML-Design-Patterns/dp/1590598040"&gt;http://www.amazon.com/Pro-CSS-HTML-Design-Patterns/dp/1590598040&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;contiene la informacion acerca de estandares, los tips y las mejores practicas para css, tambien les recomiendo firebug en sus navegadores firefox para depuracion de css&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Xg6DzYXH1fc/SiFPoIWVQwI/AAAAAAAAAAY/MlICvt5H2F8/s1600-h/41Tb7BGY2kL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 240px; height: 240px;" src="http://1.bp.blogspot.com/_Xg6DzYXH1fc/SiFPoIWVQwI/AAAAAAAAAAY/MlICvt5H2F8/s320/41Tb7BGY2kL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg" alt="" id="BLOGGER_PHOTO_ID_5341638183892632322" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;muy excelente libro lo recomiendo bastante en especial a los que les encanta hacer paginas web con diseños asombrosos, luego les recomiendo alguno para seo por mientras es todo.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-1109357401873557334?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/1109357401873557334/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=1109357401873557334' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/1109357401873557334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/1109357401873557334'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/05/correcciones-del-sistema.html' title='correcciones del sistema'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Xg6DzYXH1fc/SiFPoIWVQwI/AAAAAAAAAAY/MlICvt5H2F8/s72-c/41Tb7BGY2kL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-3487605007826491489</id><published>2009-05-16T21:15:00.000-07:00</published><updated>2009-05-16T21:30:36.526-07:00</updated><title type='text'>buscador de objetos version 1.1</title><content type='html'>hola de nuevo, esta vez estoy publicando mi propia libreria para hacer busquedas en bases de datos, esta se comporta como un odbms, o un sistema de bases de datos de objetos, lo cual es diferente a un rdbms, debido a lo que se almacena no son registros, sino objetos, esta se conecta a un rdbms, haciendo que la forma de programar sea mas sencilla, debido a que uno ya no se dedica a buscar registros, sino objetos, esto hace que la programacion orientada a objetos sea mas sencilla, la pagina es:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://sourceforge.net/project/showfiles.php?group_id=250622&amp;amp;package_id=306312"&gt;http://sourceforge.net/project/showfiles.php?group_id=250622&amp;amp;package_id=306312&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;ahi se encuentra la libreria principal, un projecto de prueba en java server faces y un script de base de datos mysql para poder generar el proyecto de prueba, aun me falta documentacion del sistema pero ya voy por menos, esta vez prometo sacarla lo antes posible, el sistema recibira actualizaciones frecuentemente asi que no se preocupen los que siguen el post, mandenme algunas sugerencias y sientanse libres de inspeccionar el codigo, recuerden que el opensource hace nuestras vidas mas productivas y mejores en muchos aspectos, gracias a eso es que avanzamos mas como personas y tambien en cuestiones tecnologicas.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-3487605007826491489?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/3487605007826491489/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=3487605007826491489' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/3487605007826491489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/3487605007826491489'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/05/buscador-de-objetos-version-11.html' title='buscador de objetos version 1.1'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-4164511463551317832</id><published>2009-05-06T17:31:00.000-07:00</published><updated>2009-05-06T18:05:33.280-07:00</updated><title type='text'>Reflection</title><content type='html'>bueno hoy me lanzo a publicar algo de programación, en esta ocasion sera acerca de algo llamado reflection, ¿Qué es reflection?, reflection es un proceso en el cual el programa puede examinar y modificar su propia estructura y comportamiento, este tipo de programacion es la llamada programacion reflexiva, las ventajas de este tipo de programacion son varias, principalmente para convertir objetos a estructuras de datos , esto se usa normalmente para serializar , las aplicaciones pueden autoserializarse para convertir xml, extraer comportamientos, fabricar librerias inteligentes y muchas cosas mas, las posibilidades son bastantes, en cuanto a lo que se puede hacer.&lt;br /&gt;&lt;br /&gt;aqui tenemos un ejemplo de uso de reflection.&lt;br /&gt;&lt;br /&gt;public Object pullObjectFromProperty(Object o, String property) throws Exception {&lt;br /&gt;    //gets the current class&lt;br /&gt;    Class _class =  o.getClass();&lt;br /&gt;    //gets the field of the object&lt;br /&gt;    Field field  = _class.getDeclaredField(property);&lt;br /&gt;    Object result = null;&lt;br /&gt;    field.setAccessible(true);&lt;br /&gt;    //assign the value of the field to a result&lt;br /&gt;    result = field.get(o);&lt;br /&gt;    return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;el siguiente fragmento puede sacar el valor del objeto conociendo el nombre del campo, tambien es posible obtener una lista de campos del objeto, una vez que conocemos esto podemos sacar las propiedades del objeto, tambien es posible invocar metodos o en dado caso obtener los metodos y saber como invocarlos, esto proporciona muchas ventajas a la hora de programar, podemos extraer la informacion de las superclases, interfaces y demas, todo esto y mas nos permite reflection, esto se genera al momento de ejecucion, como todo no debe de abusarse de esta tecnologia, debido a que puede hacer que una aplicacion disminuya su rendimiento, muestre comportamientos no adecuados, genere cosas inesperadas, sin embargo bien utilizada puede ser la herramienta perfecta.&lt;br /&gt;&lt;br /&gt;recomiendo el siguiente libro de reflection, excelente libro.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.manning.com/forman/"&gt;http://www.manning.com/forman/&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.manning.com/forman/forman_cover150.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 150px; height: 188px;" src="http://www.manning.com/forman/forman_cover150.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-4164511463551317832?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/4164511463551317832/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=4164511463551317832' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/4164511463551317832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/4164511463551317832'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/05/reflection.html' title='Reflection'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-6231964304080389744</id><published>2009-04-27T06:33:00.000-07:00</published><updated>2009-04-27T06:42:48.823-07:00</updated><title type='text'>emergenciasmac.com.mx</title><content type='html'>pues recientemente quisimos recuperar informacion de un disco duro iomega, de los de 360 gb debido a un formato accidental, y pues mi compañero jorge de la peña, le hablo a una empresa que se dedica a recuperar informacion de discos duros y demas,en ese aspecto ellos estaban por abrir su disco duro, jorge les dijo que no lo hicieran y despues recuperaron la informacion y le dieron formato completo al disco, evitando que fuere recuperable y ademas dijeron en tono ironico, aqui tenemos tus datos, de esa manera es un servicio que no tiene una forma etica de trabajar, en este caso si tienen emergencias para recuperar informacion de los discos duros, mejor usen programas como el ontrack, si necesitan info de donde descargarlo se los comentare en el proximo post, por mientras me despido :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-6231964304080389744?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/6231964304080389744/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=6231964304080389744' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/6231964304080389744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/6231964304080389744'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/04/emergenciasmaccommx.html' title='emergenciasmac.com.mx'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-8225783756822789635</id><published>2009-03-20T16:35:00.000-07:00</published><updated>2009-03-20T16:42:38.075-07:00</updated><title type='text'>action man sucks</title><content type='html'>hoy les quiero contar algo, en el blog de oscar arzona, amigo mio, y excelente programador php, nos compartio su blog &lt;a href="http://oscararzola.com/blog/?p=176&amp;cpage=1#comment-364"&gt;http://oscararzola.com/blog&lt;/a&gt; con excelentes articulos, comentarios del mundo de la programaci&amp;oacute;n recibio comentarios fuera de lugar en un foro que no tiene nada que ver con lo que es trato personal y forma de trabajo, absolutamente  nada que ver uno con el otro, en este caso se trata de un antiguo compañero de trabajo, frustrado y convertido en el titere de un cliente, en fin uno de mis mas fuertes proyectos, junto con el sistema para desarrollo de querys, les traere un adelanto la proxima semana, debido a que estoy terminando la documentaci&amp;oacute;n y ejemplos necesarios para poder echarlo a andar, espero sus comentarios y dudas. En fin mi recomendaci&amp;oacute;n es que digan las cosas como deben de ser y no se anden ocultando, esto solo los hace ver como un monton de cobardes, los verdaderos y originales nunca andamos como anonimos, en fin un saludo para aquellos que leen el blog y nos leemos proximamente.....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-8225783756822789635?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/8225783756822789635/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=8225783756822789635' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/8225783756822789635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/8225783756822789635'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/03/action-man-sucks.html' title='action man sucks'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-3486838262117479858</id><published>2009-02-12T08:51:00.000-08:00</published><updated>2009-02-12T08:52:13.730-08:00</updated><title type='text'>ofix 2oo7 original</title><content type='html'>tenía una clave no válida hasta que encontré un método que si me funcionó y sin necesitar nada de esos molestos cracks que ni me funcionaron .&lt;br /&gt;Bueno aquí va como hacer dicho método:&lt;br /&gt;1. Primero debemos cerrar todo producto de Microsoft Office.&lt;br /&gt;2. Vamos a Inicio &gt; Ejecutar &gt; Escribimos regedit&lt;br /&gt;&lt;br /&gt;3. Debemos buscar esta entrada:&lt;br /&gt;HKEY_LOCAL_MACHINE\Software\Microsoft\Office\12.0\ Registro (ami me aparece “Registration”)&lt;br /&gt;&lt;br /&gt;Una vez encontrada dicha entrada, debemos de buscar otra subentrada como esta:&lt;br /&gt;HKEY_LOCAL_MACHINE\Software\Microsoft\Office\12.0\ Registro\ {90120000-0030-0000-0000-0000000FF1CE&lt;br /&gt;&lt;br /&gt;O una como esta:&lt;br /&gt;HKEY_LOCAL_MACHINE\Software\Microsoft\Office\12.0\ Registro\ {91120000-0011-0000-0000-0000000FF1CE&lt;br /&gt;&lt;br /&gt;4. Debes de asegurarte que aparezca dentro de esas subentradas el nombre del producto del Office, como por ejemplo:&lt;br /&gt;ProductName=Microsoft Office Professional Plus 2007&lt;br /&gt;ProductName=Microsoft Office Enterprise 2007&lt;br /&gt;&lt;br /&gt;5. Una vez encontrada las algunas de las claves antes mencionadas, busca estas entradas del regedit y eliminalas:&lt;br /&gt;DigitalProductID&lt;br /&gt;ProductID&lt;br /&gt;Lo que hicimos fue borrar la clave del producto del Microsoft Office, ahora haremos que nunca más la pida.&lt;br /&gt;6. Vamos a la carpeta de instalación del Microsoft Office 2007, que debe de estar en esta dirección:&lt;br /&gt;C:\Archivos de programa\Archivos comunes\Microsoft Shared\OFFICE12\Office Setup Controller\Proof.es&lt;br /&gt;&lt;br /&gt;También debemos hacerlo para la carpeta Proof.en, que es esta:&lt;br /&gt;C:\Archivos de programa\Archivos comunes\Microsoft Shared\OFFICE12\Office Setup Controller\Proof.en&lt;br /&gt;Buscamos el archivo: proof.xml y lo abrimos con el Bloc de Notas *&lt;br /&gt;Y editamos la penúltima línea:&lt;br /&gt;&lt;feature id="”SetupXmlFiles”" cost="”1359″"&gt;&lt;br /&gt;&lt;optionref id="”AlwaysInstalled”/"&gt;&lt;br /&gt;&lt;/feature&gt;&lt;br /&gt;&lt;br /&gt;Le quitamos el AlwaysInstalled y le ponemos: neverInstalled. Debe de quedar algo así:&lt;br /&gt;&lt;feature id="”SetupXmlFiles”" cost="”1359″"&gt;&lt;br /&gt;&lt;optionref id="”neverInstalled”/"&gt;&lt;br /&gt;&lt;/feature&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Después de todo ese rollote vamos ahttp://www.microsoft.com/genuine/ le damos en "Validar Office" y listo Office Validado al 100%.&lt;br /&gt;Este método también sirve para los que compraron máquinas nuevas con Vista y que traen la versión de prueba de 30 días&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-3486838262117479858?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/3486838262117479858/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=3486838262117479858' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/3486838262117479858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/3486838262117479858'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/02/ofix-2oo7-original.html' title='ofix 2oo7 original'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-8205703109974119544</id><published>2009-01-28T08:44:00.000-08:00</published><updated>2009-01-28T11:12:17.380-08:00</updated><title type='text'></title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Xg6DzYXH1fc/SYCLtgI9fOI/AAAAAAAAAAM/lgwYIGtvUfE/s1600-h/oyster07_misspsycho.jpg"&gt;&lt;img style="cursor: pointer; width: 320px; height: 227px;" src="http://2.bp.blogspot.com/_Xg6DzYXH1fc/SYCLtgI9fOI/AAAAAAAAAAM/lgwYIGtvUfE/s320/oyster07_misspsycho.jpg" alt="" id="BLOGGER_PHOTO_ID_5296386775625596130" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Este codigo sirve para activar tu w1nd0w5 xP y dejarlo como original, solo copia el codigo y pegalo en un bloc de notas y guardalo como licencia.reg , dale doble clic y listo.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Windows Registry Editor Version 5.00&lt;br /&gt;&lt;br /&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]&lt;br /&gt;&lt;br /&gt;"CurrentBuild"="1.511.1 () (Obsolete data - do not use)"&lt;br /&gt;"ProductId"="55274-640-1011873-23081"&lt;br /&gt;&lt;br /&gt;"DigitalProductId"=hex:a4,00,00,00,03,00,00,00 ,35, 35,32,37,34,2d,36,34,30,2d,\&lt;br /&gt;&lt;br /&gt;31,30,31,31,38,37,33,2d,32,33,30,38,31,00,2e,00,00 ,00,41,32,32,2d,30,30,30,\&lt;br /&gt;&lt;br /&gt;30,31,00,00,00,00,00,00,00,86,56,4e,4c,21,1b,2b,6a ,a3,78,8e,8f,98,5c,00,00,\&lt;br /&gt;&lt;br /&gt;00,00,00,00,dd,da,47,41,cc,6b,06,00,00,00,00,00,00 ,00,00,00,00,00,00,00,00,\&lt;br /&gt;&lt;br /&gt;00,00,00,00,00,00,00,00,00,00,00,38,31,30,32,36,00 ,00,00,00,00,00,00,b5,16,\&lt;br /&gt;00,00,83,83,1f,38,f8,01,00,00,f5,1c,00,00,00,00,00 ,00,00,00,00,00,00,00,00,\&lt;br /&gt;&lt;br /&gt;00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ,66,e5,70,f3&lt;br /&gt;&lt;br /&gt;"LicenseInfo"=hex:33,b7,21,c1,e5,e7,cd,4b,fd,7 c,c6 ,35,51,fd,52,57,17,86,3e,18,\&lt;br /&gt;&lt;br /&gt;d3,f4,8c,8e,35,32,7b,d1,43,8d,61,38,60,a4,ca,55,c9 ,9a,35,17,46,7a,4f,91,fc,\&lt;br /&gt;&lt;br /&gt;4a,d9,db,64,5c,c4,e2,0f,34,f3,ea&lt;br /&gt;&lt;br /&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WPAEvents]&lt;br /&gt;&lt;br /&gt;"OOBETimer"=hex:ff,d5,71,d6,8b,6a,8d,6f,d5,33, 93,f d&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-8205703109974119544?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/8205703109974119544/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=8205703109974119544' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/8205703109974119544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/8205703109974119544'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/01/windows-registry-editor-version-5.html' title=''/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Xg6DzYXH1fc/SYCLtgI9fOI/AAAAAAAAAAM/lgwYIGtvUfE/s72-c/oyster07_misspsycho.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5570544920231772495.post-7586553341518773113</id><published>2009-01-22T09:39:00.000-08:00</published><updated>2009-01-22T09:43:33.343-08:00</updated><title type='text'>Expresiones Regulares</title><content type='html'>Las expresiones regulares son modelos que describen las combinaciones de caracteres en el texto. Se podrían definir como una serie de carácteres que forman un patrón, que representan a otro grupo de carácteres mayor, de tal forma que podemos comparar el patrón con otros conjuntos de carácteres para ver las coincidencias. Las expresiones regulares pueden utilizarse en múltiples lenguajes de programación pero en esta entrada vamos a ver un ejemplo de validación de formularios mediante Javascript y haciendo uso de expresiones regulares.&lt;br /&gt;&lt;br /&gt;Un buen tutorial para iniciarse en el manejo de expresiones regulares lo podemos encontrar en Desarrolloweb. Para realizar el ejemplo siguiente no hay porque conocer en profundidad su manejo. A continuación muestro una serie de tablas a modo de chuleta para que podamos utilizarlas con un simple corta y pega.&lt;br /&gt;&lt;br /&gt;La tabla siguiente contiene los caracteres especiales de las expresiones regulares.&lt;br /&gt;&lt;br /&gt;Carácter&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Texto buscado&lt;br /&gt;&lt;br /&gt;^&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Principio de entrada o línea.&lt;br /&gt;&lt;br /&gt;$&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Fin de entrada o línea.&lt;br /&gt;&lt;br /&gt;*&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;El carácter anterior 0 o más veces.&lt;br /&gt;&lt;br /&gt;+&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;El carácter anterior 1 o más veces.&lt;br /&gt;&lt;br /&gt;?&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;El carácter anterior una vez como máximo (es decir, indica que el carácter anterior es opcional).&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Cualquier carácter individual, salvo el de salto de línea.&lt;br /&gt;&lt;br /&gt;x|y&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;x o y.&lt;br /&gt;&lt;br /&gt;{n}&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Exactamente n apariciones del carácter anterior.&lt;br /&gt;&lt;br /&gt;{n,m}&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Como mínimo n y como máximo m apariciones del carácter anterior.&lt;br /&gt;&lt;br /&gt;[abc]&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Cualquiera de los caracteres entre corchetes. Especifique un rango de caracteres con un guión (por ejemplo, [a-f] es equivalente a [abcdef]).&lt;br /&gt;&lt;br /&gt;[^abc]&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Cualquier carácter que no esté entre corchetes. Especifique un rango de caracteres con un guión (por ejemplo, [^a-f] es equivalente a [^abcdef]).&lt;br /&gt;&lt;br /&gt;\b&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Límite de palabra (como un espacio o un retorno de carro).&lt;br /&gt;&lt;br /&gt;\B&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Cualquiera que no sea un límite de palabra.&lt;br /&gt;&lt;br /&gt;\d&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Cualquier carácter de dígito. Equivalente a [0-9].&lt;br /&gt;&lt;br /&gt;\D&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Cualquier carácter que no sea de dígito. Equivalente a [^0-9].&lt;br /&gt;&lt;br /&gt;\f&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Salto de página.&lt;br /&gt;&lt;br /&gt;\n&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Salto de línea.&lt;br /&gt;&lt;br /&gt;\r&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Retorno de carro.&lt;br /&gt;&lt;br /&gt;\s&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Cualquier carácter individual de espacio en blanco (espacios, tabulaciones, saltos de página o saltos de línea).&lt;br /&gt;&lt;br /&gt;\S&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Cualquier carácter individual que no sea un espacio en blanco.&lt;br /&gt;&lt;br /&gt;\t&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Tabulación.&lt;br /&gt;&lt;br /&gt;\w&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Cualquier carácter alfanumérico, incluido el de subrayado. Equivalente a [A-Za-z0-9_].&lt;br /&gt;&lt;br /&gt;\W&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Cualquier carácter que no sea alfanumérico. Equivalente a [^A-Za-z0-9_].&lt;br /&gt;&lt;br /&gt;La tabla siguiente contiene algunos de los patrones más utilizados a la hora de validar formularios. Si alguien conoce alguna expresión regular más -que pueda ser útil en la validación de formularios- la puede poner en los comentarios y yo la incorporaré a esta tabla.&lt;br /&gt;&lt;br /&gt;Cualquier letra en minuscula&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;[a-z]&lt;br /&gt;&lt;br /&gt;Entero&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;^(?:\+|-)?\d+$&lt;br /&gt;&lt;br /&gt;Correo electrónico&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;/[\w-\.]{3,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/&lt;br /&gt;&lt;br /&gt;URL&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)( [a-zA-Z0-9\-\.\?\,\’\/\\\+&amp;amp;%\$#_]*)?$&lt;br /&gt;&lt;br /&gt;Contraseña segura&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$&lt;br /&gt;(Entre 8 y 10 caracteres, por lo menos un digito y un alfanumérico, y no puede contener caracteres espaciales)&lt;br /&gt;&lt;br /&gt;Fecha&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;^\d{1,2}\/\d{1,2}\/\d{2,4}$&lt;br /&gt;(Por ejemplo 01/01/2007)&lt;br /&gt;&lt;br /&gt;Hora&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;^(0[1-9]|1\d|2[0-3]):([0-5]\d):([0-5]\d)$&lt;br /&gt;(Por ejemplo 10:45:23)&lt;br /&gt;&lt;br /&gt;Número tarjeta de crédito&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;^((67\d{2})|(4\d{3})|(5[1-5]\d{2})|(6011))(-?\s?\d{4}){3}|(3[4,7])\ d{2}-?\s?\d{6}-?\s?\d{5}$&lt;br /&gt;&lt;br /&gt;Número teléfono&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;^[0-9]{2,3}-? ?[0-9]{6,7}$&lt;br /&gt;&lt;br /&gt;Código postal&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;^([1-9]{2}|[0-9][1-9]|[1-9][0-9])[0-9]{3}$&lt;br /&gt;&lt;br /&gt;Certificado Identificación Fiscal&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;^(X(-|\.)?0?\d{7}(-|\.)?[A-Z]|[A-Z](-|\.)?\d{7}(-|\.)? [0-9A-Z]|\d{8}(-|\.)?[A-Z])$&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5570544920231772495-7586553341518773113?l=cacostamx.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cacostamx.blogspot.com/feeds/7586553341518773113/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5570544920231772495&amp;postID=7586553341518773113' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/7586553341518773113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5570544920231772495/posts/default/7586553341518773113'/><link rel='alternate' type='text/html' href='http://cacostamx.blogspot.com/2009/01/expresiones-regulares.html' title='Expresiones Regulares'/><author><name>Carlostein</name><uri>http://www.blogger.com/profile/14136157781472512230</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_Xg6DzYXH1fc/StNUHkufnNI/AAAAAAAAAAk/6mGfS2zeYfw/S220/rose.png'/></author><thr:total>0</thr:total></entry></feed>
