<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Oscar&#039;s Code</title>
	<atom:link href="http://blog.oscarscode.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.oscarscode.com</link>
	<description>.NET vs Java</description>
	<lastBuildDate>Sun, 30 Oct 2011 04:42:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.3.2</generator>
	<item>
		<title>Usar UpdateProgress Para Cubrir La Pantalla</title>
		<link>http://blog.oscarscode.com/dot-net-es/usar-updateprogress-para-cubrir-la-pantalla/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=usar-updateprogress-para-cubrir-la-pantalla</link>
					<comments>http://blog.oscarscode.com/dot-net-es/usar-updateprogress-para-cubrir-la-pantalla/#comments</comments>
		
		<dc:creator><![CDATA[Oscar Martinez]]></dc:creator>
		<pubDate>Mon, 31 Oct 2011 13:00:55 +0000</pubDate>
				<category><![CDATA[.NET @es]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET AJAX]]></category>
		<guid isPermaLink="false">http://blog.oscarscode.com/?p=582</guid>

					<description><![CDATA[<p>Como mencione en otro post, AJAX es utilizado para hacer las paginas web mas interactivas y responsivas. Vimos que el control UpdatePanel es una manera fÃ¡cil de aÃ±adir funciones AJAX a una pagina web. Pero hay ocasiones en que una operaciÃ³n no se puede completar muy rÃ¡pido, asÃ­ que para el usuario puede parecer como [&#8230;]</p>
The post <a href="http://blog.oscarscode.com/dot-net-es/usar-updateprogress-para-cubrir-la-pantalla/">Usar UpdateProgress Para Cubrir La Pantalla</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></description>
										<content:encoded><![CDATA[<p>Como mencione en otro post, <a title="IntroducciÃ³n a ASP.NET AJAX" href="/?p=405">AJAX es utilizado para hacer las paginas web mas interactivas y responsivas</a>. Vimos que el control UpdatePanel es una manera fÃ¡cil de aÃ±adir funciones AJAX a una pagina web.</p>
<p>Pero hay ocasiones en que una operaciÃ³n no se puede completar muy rÃ¡pido, asÃ­ que para el usuario puede parecer como que nada esta pasando en la pagina.</p>
<p>ASP.NET ofrece el control <em>UpdateProgress</em> para mostrar contenido HTML al usuario mientras el navegador esta esperando que una operaciÃ³n AJAX termine.</p>
<p>Por favor observa que un control UpdateProgress puede ser asociado con un control UpdatePanel en especifico o puede ser disparado por cualquier UpdatePanel en la pagina.</p>
<p>Crea una AplicaciÃ³n Web ASP.NET.</p>
<p>Abre la pagina Default.aspx y copia el cÃ³digo siguiente.</p>
<pre class="brush:html">&lt;%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="CoverScreen._Default" %&gt;

&lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt;
&lt;/asp:Content&gt;
&lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt;

    &lt;style type="text/css"&gt;
        .overlay  
        {
    	    position: fixed;
    	    z-index: 98;
    	    top: 0px;
    	    left: 0px;
    	    right: 0px;
    	    bottom: 0px;
            background-color: #aaa; 
            filter: alpha(opacity=80); 
            opacity: 0.8; 
        }
        .overlayContent
        {
    	    z-index: 99;
    	    margin: 250px auto;
    	    width: 80px;
    	    height: 80px;
        }
        .overlayContent h2
        {
            font-size: 18px;
            font-weight: bold;
            color: #000;
        }
        .overlayContent img
        {
    	    width: 80px;
    	    height: 80px;
        }
    &lt;/style&gt;

    &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
    &lt;/asp:ScriptManager&gt;

    &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
        &lt;ContentTemplate&gt;
            &lt;asp:Button ID="Button1" runat="server" Text="Click Me" onclick="Button1_Click" /&gt;
        &lt;/ContentTemplate&gt;
    &lt;/asp:UpdatePanel&gt;

    &lt;asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0" AssociatedUpdatePanelID="UpdatePanel1"&gt;
        &lt;ProgressTemplate&gt;
            &lt;div class="overlay" /&gt;
            &lt;div class="overlayContent"&gt;
                &lt;h2&gt;Loading...&lt;/h2&gt;
                &lt;img src="Images/ajax-loader.gif" alt="Loading" border="1" /&gt;
            &lt;/div&gt;
        &lt;/ProgressTemplate&gt;
    &lt;/asp:UpdateProgress&gt;

&lt;/asp:Content&gt;</pre>
<p>Primero tenemos una secciÃ³n <em>style</em>. La clase <em>overlay</em> serÃ¡ utilizada para cubrir la pantalla con un <em>div</em> semitransparente. El div serÃ¡ hecho visible por el control UpdateProgress cuando sea necesario.</p>
<p>Para utilizar los controles UpdatePanel y UpdateProgress necesitamos agregar un control <em>ScriptManager</em>.</p>
<p>DespuÃ©s agregamos el UpdatePanel con un botÃ³n para disparar un postback asÃ­ncrono.</p>
<p>Finalmente agregamos el control UpdateProgress. Este control tiene los elementos <em>div</em> que serÃ¡n hechos visibles cada vez que el botÃ³n sea presionado. El primer div cubrirÃ¡ toda la pantalla gracias al estilo que definimos anteriormente. DespuÃ©s mostramos otro div con un texto y una imagen en el centro de la pantalla.</p>
<p>Para la imagen cree un <em>gif</em> animado en <a title="http://ajaxload.info/" href="http://ajaxload.info/" target="_blank">http://ajaxload.info/</a>.</p>
<p>En este ejemplo asociamos el UpdateProgress con el UpdatePanel explÃ­citamente. Esto no es realmente necesario ya que solo tenemos un UpdatePanel en la pagina.</p>
<p>Ahora editemos el cÃ³digo detrÃ¡s.</p>
<pre class="brush:csharp">using System;

namespace CoverScreen
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(3000);
        }
    }
}</pre>
<p>Todo lo que hacemos aquÃ­ es  pausar el subproceso (<em>thread</em>) por 3 segundos cuando el botÃ³n es presionado para que podamos ver el UpdateProgress en acciÃ³n.</p>
<p>Ejecuta el proyecto.</p>
<p><img decoding="async" fetchpriority="high" title="Cover Screen Sample" src="http://blog.oscarscode.com/wp-content/uploads/2011/10/cover-screen-sample-1.png" alt="Cover Screen Sample" width="644" height="446" border="0" /></p>
<p>Haz clic en el botÃ³n.</p>
<p><img decoding="async" title="Cover Screen Sample" src="http://blog.oscarscode.com/wp-content/uploads/2011/10/cover-screen-sample-2.png" alt="Cover Screen Sample" width="644" height="446" border="0" /></p>
<p>El texto <em>Loading</em> y la imagen aparecerÃ¡n por 3 segundos.</p>
<p>Puedes descargar el cÃ³digo de este ejemplo <a title="Codigo Ejemplo" href="http://blog.oscarscode.com/wp-content/uploads/2011/10/CoverScreen.zip">aquÃ­</a>.</p>
<p>Por favor deja tus comentarios.</p>The post <a href="http://blog.oscarscode.com/dot-net-es/usar-updateprogress-para-cubrir-la-pantalla/">Usar UpdateProgress Para Cubrir La Pantalla</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></content:encoded>
					
					<wfw:commentRss>http://blog.oscarscode.com/dot-net-es/usar-updateprogress-para-cubrir-la-pantalla/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
		<item>
		<title>Use UpdateProgress To Cover Screen</title>
		<link>http://blog.oscarscode.com/dot-net/use-updateprogress-to-cover-screen/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=use-updateprogress-to-cover-screen</link>
					<comments>http://blog.oscarscode.com/dot-net/use-updateprogress-to-cover-screen/#comments</comments>
		
		<dc:creator><![CDATA[Oscar Martinez]]></dc:creator>
		<pubDate>Mon, 31 Oct 2011 13:00:33 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET AJAX]]></category>
		<guid isPermaLink="false">http://blog.oscarscode.com/?p=470</guid>

					<description><![CDATA[<p>As I mentioned in another post, AJAX is used to make web pages more interactive and responsive. We saw that the UpdatePanel control is an easy way of adding AJAX to a web page. But there are times when an operation canâ€™t be completed quickly, so to the user it might seem like nothing is [&#8230;]</p>
The post <a href="http://blog.oscarscode.com/dot-net/use-updateprogress-to-cover-screen/">Use UpdateProgress To Cover Screen</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></description>
										<content:encoded><![CDATA[<p>As I mentioned in another post, <a title="Introduction to ASP.NET AJAX" href="/?p=373">AJAX is used to make web pages more interactive and responsive</a>. We saw that the UpdatePanel control is an easy way of adding AJAX to a web page.</p>
<p>But there are times when an operation canâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />t be completed quickly, so to the user it might seem like nothing is going on.</p>
<p>ASP.NET offers the <em>UpdateProgress</em> control to show HTML content to the user while the browser is waiting for an AJAX operation to complete.</p>
<p>Please note that an UpdateProgress control can be associated to a specific UpdatePanel control, or it can be triggered by any UpdatePanel in the page.</p>
<p>Go ahead and create a new ASP.NET Web Application.</p>
<p>Open the Default.aspx page and copy the following code.</p>
<pre class="brush:html">&lt;%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="CoverScreen._Default" %&gt;

&lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt;
&lt;/asp:Content&gt;
&lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt;

    &lt;style type="text/css"&gt;
        .overlay
        {
    	    position: fixed;
    	    z-index: 98;
    	    top: 0px;
    	    left: 0px;
    	    right: 0px;
    	    bottom: 0px;
            background-color: #aaa;
            filter: alpha(opacity=80);
            opacity: 0.8;
        }
        .overlayContent
        {
    	    z-index: 99;
    	    margin: 250px auto;
    	    width: 80px;
    	    height: 80px;
        }
        .overlayContent h2
        {
            font-size: 18px;
            font-weight: bold;
            color: #000;
        }
        .overlayContent img
        {
    	    width: 80px;
    	    height: 80px;
        }
    &lt;/style&gt;

    &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
    &lt;/asp:ScriptManager&gt;

    &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
        &lt;ContentTemplate&gt;
            &lt;asp:Button ID="Button1" runat="server" Text="Click Me" onclick="Button1_Click" /&gt;
        &lt;/ContentTemplate&gt;
    &lt;/asp:UpdatePanel&gt;

    &lt;asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0" AssociatedUpdatePanelID="UpdatePanel1"&gt;
        &lt;ProgressTemplate&gt;
            &lt;div class="overlay" /&gt;
            &lt;div class="overlayContent"&gt;
                &lt;h2&gt;Loading...&lt;/h2&gt;
                &lt;img src="Images/ajax-loader.gif" alt="Loading" border="1" /&gt;
            &lt;/div&gt;
        &lt;/ProgressTemplate&gt;
    &lt;/asp:UpdateProgress&gt;

&lt;/asp:Content&gt;</pre>
<p>First, youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll see a <em>style</em> section. The <em>overlay</em> class will be used to cover the screen with a semi-transparent <em>div</em>. That div will be made visible by the UpdateProgress control when necessary.</p>
<p>In order to use the UpdatePanel and UpdateProgress controls we need to add a <em>ScriptManager</em> control.</p>
<p>Then, we add the UpdatePanel with a button to trigger an asynchronous post-back.</p>
<p>Finally, we add the UpdateProgress control. This control has the <em>div</em> elements that will be made visible every time the button is clicked. The first div will cover the whole screen thanks to the style we defined earlier. Then, we show another div with some text and an image in the center of the screen.</p>
<p>For the image I created an animated <em>gif</em> on <a title="http://ajaxload.info/" href="http://ajaxload.info/" target="_blank">http://ajaxload.info/</a>.</p>
<p>In this sample, we explicitly associated the UpdateProgress to the UpdatePanel. This is not really necessary since we only have one UpdatePanel in the page.</p>
<p>Now edit the code behind.</p>
<pre class="brush:csharp">using System;

namespace CoverScreen
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(3000);
        }
    }
}</pre>
<p>All we do here is to pause the thread for 3 seconds when the button is clicked so that we can see the UpdateProgress in action.</p>
<p>Run the project.</p>
<p><img decoding="async" title="Cover Screen Sample" src="http://blog.oscarscode.com/wp-content/uploads/2011/10/cover-screen-sample-1.png" alt="Cover Screen Sample" width="644" height="446" border="0" /></p>
<p>Click on the button.</p>
<p><img decoding="async" loading="lazy" title="Cover Screen Sample" src="http://blog.oscarscode.com/wp-content/uploads/2011/10/cover-screen-sample-2.png" alt="Cover Screen Sample" width="644" height="446" border="0" /></p>
<p>The <em>Loading</em> text and image will appear for 3 seconds.</p>
<p>You can download the sample code <a title="Code Sample" href="http://blog.oscarscode.com/wp-content/uploads/2011/10/CoverScreen.zip">here</a>.</p>
<p>Please leave your comments.</p>The post <a href="http://blog.oscarscode.com/dot-net/use-updateprogress-to-cover-screen/">Use UpdateProgress To Cover Screen</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></content:encoded>
					
					<wfw:commentRss>http://blog.oscarscode.com/dot-net/use-updateprogress-to-cover-screen/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>Create Charts in ASP.NET</title>
		<link>http://blog.oscarscode.com/dot-net/create-charts-in-asp-net/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-charts-in-asp-net</link>
					<comments>http://blog.oscarscode.com/dot-net/create-charts-in-asp-net/#comments</comments>
		
		<dc:creator><![CDATA[Oscar Martinez]]></dc:creator>
		<pubDate>Tue, 06 Sep 2011 13:00:49 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Charts]]></category>
		<guid isPermaLink="false">http://blog.oscarscode.com/?p=421</guid>

					<description><![CDATA[<p>The Microsoft Chart control allows us to easily create many types of charts in Windows applications and in ASP.NET applications. If youâ€™re using .NET 3.5 (Visual Studio 2008), you will need to download a separate installer from Microsoftâ€™s download page. Optionally, you can also download an Add-on for Visual Studio 2008 that will add the [&#8230;]</p>
The post <a href="http://blog.oscarscode.com/dot-net/create-charts-in-asp-net/">Create Charts in ASP.NET</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></description>
										<content:encoded><![CDATA[<p>The Microsoft <em>Chart</em> control allows us to easily create many types of charts in Windows applications and in ASP.NET applications.</p>
<p>If youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />re using .NET 3.5 (Visual Studio 2008), you will need to download a separate installer from <a title="Microsoft Chart Controls for Microsoft .NET Framework 3.5" href="http://www.microsoft.com/download/en/details.aspx?id=14422" target="_blank">Microsoftâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s download page</a>. Optionally, you can also <a title="Microsoft Chart Controls Add-on for Microsoft Visual Studio 2008" href="http://www.microsoft.com/download/en/details.aspx?id=23903" target="_blank">download an Add-on for Visual Studio 2008</a> that will add the Chart control to the <em>Toolbox</em>.</p>
<p>Starting with .NET 4 (Visual Studio 2010), the Microsoft Chart control is part of the framework. You donâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />t need to download anything else.</p>
<p>Create a new ASP.NET Web Application and add a reference to <em>System.Web.DataVisualization</em>.</p>
<p><img decoding="async" loading="lazy" title="System.Web.DataVisualization" src="http://blog.oscarscode.com/wp-content/uploads/2011/09/system-web-datavisualization.png" alt="System.Web.DataVisualization" width="467" height="390" border="0" /></p>
<p>If youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />re using Visual Studio 2010 or if you installed the Add-on for Visual Studio 2008, youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll see the Chart control in the <em>Toolbox</em> under the <em>Data</em> section.</p>
<p><img decoding="async" loading="lazy" title="Chart Control" src="http://blog.oscarscode.com/wp-content/uploads/2011/09/chart-control.png" alt="Chart Control" width="295" height="205" border="0" /></p>
<p>Before you can start using the Chart control, you need to set up an <em>http handler</em> in the web.config for the path <em>ChartImg.axd</em>.</p>
<p>For .NET 3.5, add the following inside the <em>&lt;system.web&gt;</em> section.</p>
<pre class="brush:xml">    &lt;httpHandlers&gt;
      &lt;add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/&gt;
    &lt;/httpHandlers&gt;</pre>
<p>And hereâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s the one for .NET 4.</p>
<pre class="brush:xml">    &lt;httpHandlers&gt;
      &lt;add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/&gt;
    &lt;/httpHandlers&gt;</pre>
<p>This is how the browser will request the chart to the web server. If you donâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />t add this http handler to the web.config, youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll get the following error.</p>
<blockquote><p>Error executing child request for ChartImg.axd</p></blockquote>
<p>To start using the Chart control in a page, youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll need to register it first like this:</p>
<pre class="brush:xml">&lt;%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %&gt;</pre>
<p>If you want to make the control available to all the pages in your application, you can register the Chart control in the web.config:</p>
<pre class="brush:xml">&lt;pages&gt;
      &lt;controls&gt;
        &lt;add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&gt;
      &lt;/controls&gt;
    &lt;/pages&gt;</pre>
<p>Change the assembly version if youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />re using .NET 3.5.</p>
<p>Letâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s add a couple of charts to a web page. Iâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll use the Default.aspx page.</p>
<pre class="brush:xml">&lt;%@ Page Title="Chart Sample" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="ChartSample._Default" %&gt;

&lt;%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %&gt;

&lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt;
&lt;/asp:Content&gt;
&lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt;

    &lt;asp:Chart ID="Chart1" runat="server" Width="400px" Height="300px" Palette="BrightPastel" BackColor="Silver" BackSecondaryColor="White" BackGradientStyle="TopBottom"&gt;
        &lt;Series&gt;
            &lt;asp:Series Name="Series1" ChartType="Column" ChartArea="ChartArea1"&gt;
            &lt;/asp:Series&gt;
        &lt;/Series&gt;
        &lt;ChartAreas&gt;
            &lt;asp:ChartArea Name="ChartArea1" BackSecondaryColor="White" BackColor="Gainsboro" BackGradientStyle="DiagonalLeft"&gt;
            &lt;/asp:ChartArea&gt;
        &lt;/ChartAreas&gt;
        &lt;Titles&gt;
            &lt;asp:Title Text="Sales per Month" /&gt;
        &lt;/Titles&gt;
        &lt;BorderSkin SkinStyle="Emboss" /&gt;
    &lt;/asp:Chart&gt;

    &lt;asp:Chart ID="Chart2" runat="server" Width="400px" Height="300px" Palette="BrightPastel" BackColor="Silver" BackSecondaryColor="White" BackGradientStyle="TopBottom"&gt;
        &lt;Series&gt;
            &lt;asp:Series Name="Series1" ChartType="Pie" ChartArea="ChartArea1" Legend="Default" Label="#PERCENT{P2}" LegendText="#VALX"&gt;
            &lt;/asp:Series&gt;
        &lt;/Series&gt;
        &lt;ChartAreas&gt;
            &lt;asp:ChartArea Name="ChartArea1" BackColor="Transparent"&gt;
            &lt;/asp:ChartArea&gt;
        &lt;/ChartAreas&gt;
        &lt;Titles&gt;
            &lt;asp:Title Text="Sales by Department" /&gt;
        &lt;/Titles&gt;
        &lt;Legends&gt;
            &lt;asp:Legend Name="Default" BackSecondaryColor="White" BackColor="Gainsboro" BackGradientStyle="DiagonalLeft" /&gt;
        &lt;/Legends&gt;
        &lt;BorderSkin SkinStyle="Emboss" /&gt;
    &lt;/asp:Chart&gt;

&lt;/asp:Content&gt;</pre>
<p>The first chart will be a <em>column</em> chart, and the second one will be a <em>pie</em> chart. Take a look at how we set the dimensions, the colors, and the titles and label formats. We also set up legends for the second chart.</p>
<p>We could also define the lists of points for our series here. But in this case, weâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll add the points in the code behind.</p>
<p>Letâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s define the data weâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll use to populate the charts. Iâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll show you two types of data sources we can use to populate the points for the charts. Add a new class to the project and name it <em>DataAccess</em>.</p>
<p>For the first chart, weâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll use a <em>DataTable</em> to represent data from a database. For the second chart, weâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll use a collection of <em>objects</em> that would represent a <em>model</em> in our application.</p>
<pre class="brush:csharp">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace ChartSample
{
    public class DataAccess
    {
        public static DataTable GetSalesPerMonth()
        {
            DataTable dt = new DataTable();

            DataColumn col = new DataColumn();
            col.ColumnName = "Month";
            col.DataType = typeof(String);
            dt.Columns.Add(col);

            col = new DataColumn();
            col.ColumnName = "Sales";
            col.DataType = typeof(Decimal);
            dt.Columns.Add(col);

            DataRow row = dt.NewRow();
            row["Month"] = "July";
            row["Sales"] = 122000m;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Month"] = "August";
            row["Sales"] = 96000m;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Month"] = "September";
            row["Sales"] = 135000m;
            dt.Rows.Add(row);

            dt.AcceptChanges();

            return dt;
        }

        public static IEnumerable&lt;Sale&gt; GetSalesByDepartment()
        {
            List&lt;Sale&gt; sales = new List&lt;Sale&gt;();

            Sale s = new Sale();
            s.Department = "Service";
            s.Sales = 35000m;
            sales.Add(s);

            s = new Sale();
            s.Department = "Stores";
            s.Sales = 60000m;
            sales.Add(s);

            s = new Sale();
            s.Department = "Internet";
            s.Sales = 40000m;
            sales.Add(s);

            return sales;
        }
    }

    public class Sale
    {
        public String Department { get; set; }
        public Decimal Sales { get; set; }
    }
}</pre>
<p>In a real application, these methods would probably read data from a database, but to keep the sample simple, Iâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ve hard coded some data. The first method returns a <em>DataTable</em>, while the second method returns a list of objects.</p>
<p>Now open the Default.aspx.cs file and add the following code.</p>
<pre class="brush:csharp">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace ChartSample
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindCharts();
            }
        }

        private void BindCharts()
        {
            DataTable dt = DataAccess.GetSalesPerMonth();
            DataView data = new DataView(dt);
            Chart1.Series["Series1"].Points.DataBind(data, "Month", "Sales", "");

            IEnumerable&lt;Sale&gt; data2= DataAccess.GetSalesByDepartment();
            Chart2.Series["Series1"].Points.DataBind(data2, "Department", "Sales", "");
        }
    }
}</pre>
<p>A chart can have multiple series, and a series is nothing more that a collection of points. Each point has an <em>X value</em> and a <em>Y value</em>.</p>
<p>We could use a loop to add each point to the <em>Points</em> property. This would probably be the case if we were capturing the values from the user.</p>
<p>When we already have data from another source, such as a database, we simply use the <em>DataBind</em> method.</p>
<p>The first parameter is a <em><a title="IEnumerable Interface" href="http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx" target="_blank">IEnumerable</a></em> collection, such as a <em><a title="List Class" href="http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx" target="_blank">List</a></em>. This is why we canâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />t use the <em>DataTable</em> object directly and need to create a <em><a title="DataView Class" href="http://msdn.microsoft.com/en-us/library/system.data.dataview.aspx" target="_blank">DataView</a></em> object.</p>
<p>The second parameter is the name of the field or property for the <em>X values</em>, and the third parameter the field or property for the <em>Y values</em>.</p>
<p>Run the project.</p>
<p><img decoding="async" loading="lazy" title="Chart Sample" src="http://blog.oscarscode.com/wp-content/uploads/2011/09/chart-sample.png" alt="Chart Sample" width="644" height="471" border="0" /></p>
<p>Please leave your comments.</p>The post <a href="http://blog.oscarscode.com/dot-net/create-charts-in-asp-net/">Create Charts in ASP.NET</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></content:encoded>
					
					<wfw:commentRss>http://blog.oscarscode.com/dot-net/create-charts-in-asp-net/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Crear Graficas en ASP.NET</title>
		<link>http://blog.oscarscode.com/dot-net-es/crear-graficas-en-asp-net/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=crear-graficas-en-asp-net</link>
					<comments>http://blog.oscarscode.com/dot-net-es/crear-graficas-en-asp-net/#comments</comments>
		
		<dc:creator><![CDATA[Oscar Martinez]]></dc:creator>
		<pubDate>Tue, 06 Sep 2011 13:00:26 +0000</pubDate>
				<category><![CDATA[.NET @es]]></category>
		<category><![CDATA[ASP.NET @es]]></category>
		<category><![CDATA[Graficas]]></category>
		<guid isPermaLink="false">http://blog.oscarscode.com/?p=579</guid>

					<description><![CDATA[<p>El control Chart (Grafica) nos permite crear fÃ¡cilmente muchos tipos de graficas en aplicaciones Windows y en aplicaciones ASP.NET. Si estas usando .NET 3.5 (Visual Studio 2008), necesitaras descargar un instalador aparte de la pagina de descarga de Microsoft. Opcionalmente puedes descargar un Add-on para Visual Studio 2008 que agregara el control Chart al Cuadro [&#8230;]</p>
The post <a href="http://blog.oscarscode.com/dot-net-es/crear-graficas-en-asp-net/">Crear Graficas en ASP.NET</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></description>
										<content:encoded><![CDATA[<p>El control <em>Chart</em> (Grafica) nos permite crear fÃ¡cilmente muchos tipos de graficas en aplicaciones Windows y en aplicaciones ASP.NET.</p>
<p>Si estas usando .NET 3.5 (Visual Studio 2008), necesitaras descargar un instalador aparte de la <a title="Microsoft Chart Controls for Microsoft .NET Framework 3.5" href="http://www.microsoft.com/download/en/details.aspx?id=14422" target="_blank">pagina de descarga de Microsoft</a>. Opcionalmente puedes <a title="Microsoft Chart Controls Add-on for Microsoft Visual Studio 2008" href="http://www.microsoft.com/download/en/details.aspx?id=23903" target="_blank">descargar un Add-on para Visual Studio 2008</a> que agregara el control Chart al <em>Cuadro de Herramientas</em>.</p>
<p>Comenzando con .NET 4 (Visual Studio 2010), el control Microsoft Chart es parte del framework. No es necesario descargar nada mas.</p>
<p>Crea un nueva AplicaciÃ³n Web ASP.NET y agrega una referencia a <em>System.Web.DataVisualization</em>.</p>
<p><img decoding="async" loading="lazy" title="System.Web.DataVisualization" src="http://blog.oscarscode.com/wp-content/uploads/2011/09/system-web-datavisualization.png" alt="System.Web.DataVisualization" width="467" height="390" border="0" /></p>
<p>Si estas utilizando Visual Studio 2010 o si instalaste el Add-on para Visual Studio 2008, veras el control Chart en el <em>Cuadro de Herramientas</em> debajo de la secciÃ³n <em>Datos</em>.</p>
<p><img decoding="async" loading="lazy" title="Control Chart" src="http://blog.oscarscode.com/wp-content/uploads/2011/09/chart-control.png" alt="Control Chart" width="295" height="205" border="0" /></p>
<p>Antes de poder utilizar el control Chart, es necesario establecer un <em>manejador http</em> (http handler) en el web.config para la ruta <em>ChartImg.axd</em>.</p>
<p>Para .NET 3.5, agrega lo siguiente dentro de la secciÃ³n <em>&lt;system.web&gt;</em>.</p>
<pre class="brush:xml">    &lt;httpHandlers&gt;
      &lt;add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/&gt;
    &lt;/httpHandlers&gt;</pre>
<p>Y aquÃ­ esta para .NET 4.</p>
<pre class="brush:xml">    &lt;httpHandlers&gt;
      &lt;add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/&gt;
    &lt;/httpHandlers&gt;</pre>
<p>AsÃ­ es como el navegador solicitara la grafica del servidor . Si no agregas este manejador http al web.config, recibirÃ¡s el siguiente error.</p>
<blockquote><p>Error al ejecutar la solicitud secundaria para ChartImg.axd</p></blockquote>
<p>Para utilizar el control Chart en una pagina, necesitaras registrarlo primero asÃ­:</p>
<pre class="brush:xml">&lt;%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %&gt;</pre>
<p>Si quieres hacer el control disponible para todas la paginas en la aplicaciÃ³n, puedes registral el control Chart en el web.config:</p>
<pre class="brush:xml">&lt;pages&gt;
      &lt;controls&gt;
        &lt;add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&gt;
      &lt;/controls&gt;
    &lt;/pages&gt;</pre>
<p>Solo cambia la versiÃ³n si estas utilizando .NET 3.5.</p>
<p>Vamos a agregar un par de graficas a una pagina web. Utilizare la pagina Default.aspx.</p>
<pre class="brush:xml">&lt;%@ Page Title="Chart Sample" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="ChartSample._Default" %&gt;

&lt;%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %&gt;

&lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt;
&lt;/asp:Content&gt;
&lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt;

    &lt;asp:Chart ID="Chart1" runat="server" Width="400px" Height="300px" Palette="BrightPastel" BackColor="Silver" BackSecondaryColor="White" BackGradientStyle="TopBottom"&gt;
        &lt;Series&gt;
            &lt;asp:Series Name="Series1" ChartType="Column" ChartArea="ChartArea1"&gt;
            &lt;/asp:Series&gt;
        &lt;/Series&gt;
        &lt;ChartAreas&gt;
            &lt;asp:ChartArea Name="ChartArea1" BackSecondaryColor="White" BackColor="Gainsboro" BackGradientStyle="DiagonalLeft"&gt;
            &lt;/asp:ChartArea&gt;
        &lt;/ChartAreas&gt;
        &lt;Titles&gt;
            &lt;asp:Title Text="Sales per Month" /&gt;
        &lt;/Titles&gt;
        &lt;BorderSkin SkinStyle="Emboss" /&gt;
    &lt;/asp:Chart&gt;

    &lt;asp:Chart ID="Chart2" runat="server" Width="400px" Height="300px" Palette="BrightPastel" BackColor="Silver" BackSecondaryColor="White" BackGradientStyle="TopBottom"&gt;
        &lt;Series&gt;
            &lt;asp:Series Name="Series1" ChartType="Pie" ChartArea="ChartArea1" Legend="Default" Label="#PERCENT{P2}" LegendText="#VALX"&gt;
            &lt;/asp:Series&gt;
        &lt;/Series&gt;
        &lt;ChartAreas&gt;
            &lt;asp:ChartArea Name="ChartArea1" BackColor="Transparent"&gt;
            &lt;/asp:ChartArea&gt;
        &lt;/ChartAreas&gt;
        &lt;Titles&gt;
            &lt;asp:Title Text="Sales by Department" /&gt;
        &lt;/Titles&gt;
        &lt;Legends&gt;
            &lt;asp:Legend Name="Default" BackSecondaryColor="White" BackColor="Gainsboro" BackGradientStyle="DiagonalLeft" /&gt;
        &lt;/Legends&gt;
        &lt;BorderSkin SkinStyle="Emboss" /&gt;
    &lt;/asp:Chart&gt;

&lt;/asp:Content&gt;</pre>
<p>La primera grafica serÃ¡ una grafica de <em>columnas</em>, y la segunda serÃ¡ una grafica <em>circular</em>, tambiÃ©n conocida como grafica de <em>pastel</em>. Observa como establecimos las dimensiones, los colores, los tÃ­tulos y formatos de etiquetas. TambiÃ©n establecimos un cuadro de leyendas para las segunda grafica.</p>
<p>TambiÃ©n podrÃ­amos definir las listas de puntos para nuestras series aquÃ­. Pero en este caso, agregaremos los puntos con cÃ³digo.</p>
<p>Vamos a definir los datos que usaremos para poblar las graficas. Mostrare dos tipos de orÃ­genes de datos que podemos utilizar para poblar los puntos de las graficas. Agrega una nueva clase al proyecto y nÃ³mbrala <em>DataAccess</em>.</p>
<p>Para la primer grafica, utilizaremos un <em>DataTable</em> para representar informaciÃ³n de una base de datos. Para la segunda grafica, usaremos una colecciÃ³n de <em>objetos</em> para representar un <em>modelo</em> en una  aplicaciÃ³n.</p>
<pre class="brush:csharp">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace ChartSample
{
    public class DataAccess
    {
        public static DataTable GetSalesPerMonth()
        {
            DataTable dt = new DataTable();

            DataColumn col = new DataColumn();
            col.ColumnName = "Month";
            col.DataType = typeof(String);
            dt.Columns.Add(col);

            col = new DataColumn();
            col.ColumnName = "Sales";
            col.DataType = typeof(Decimal);
            dt.Columns.Add(col);

            DataRow row = dt.NewRow();
            row["Month"] = "July";
            row["Sales"] = 122000m;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Month"] = "August";
            row["Sales"] = 96000m;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Month"] = "September";
            row["Sales"] = 135000m;
            dt.Rows.Add(row);

            dt.AcceptChanges();

            return dt;
        }

        public static IEnumerable&lt;Sale&gt; GetSalesByDepartment()
        {
            List&lt;Sale&gt; sales = new List&lt;Sale&gt;();

            Sale s = new Sale();
            s.Department = "Service";
            s.Sales = 35000m;
            sales.Add(s);

            s = new Sale();
            s.Department = "Stores";
            s.Sales = 60000m;
            sales.Add(s);

            s = new Sale();
            s.Department = "Internet";
            s.Sales = 40000m;
            sales.Add(s);

            return sales;
        }
    }

    public class Sale
    {
        public String Department { get; set; }
        public Decimal Sales { get; set; }
    }
}</pre>
<p>En una aplicaciÃ³n real estos mÃ©todos probablemente leerÃ­an la informaciÃ³n de una base de datos, pero para mantener el ejemplo simple, he codificado la informaciÃ³n. El primer mÃ©todo retorna un objeto <em>DataTable</em>, mientras que el segundo retorna una lista de objetos.</p>
<p>Ahora abre el archivo Default.aspx.cs y agrega el cÃ³digo a continuaciÃ³n.</p>
<pre class="brush:csharp">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace ChartSample
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindCharts();
            }
        }

        private void BindCharts()
        {
            DataTable dt = DataAccess.GetSalesPerMonth();
            DataView data = new DataView(dt);
            Chart1.Series["Series1"].Points.DataBind(data, "Month", "Sales", "");

            IEnumerable&lt;Sale&gt; data2= DataAccess.GetSalesByDepartment();
            Chart2.Series["Series1"].Points.DataBind(data2, "Department", "Sales", "");
        }
    }
}</pre>
<p>Una grafica puede tener mÃºltiples series, y una serie no es mas que una colecciÃ³n de puntos. Cada punto tiene un <em>valor X</em> y un <em>valor Y</em>.</p>
<p>PodrÃ­amos utilizar un ciclo para aÃ±adir cada punto a la propiedad <em>Points</em>. Este podrÃ­a ser el caso si estuviÃ©ramos capturando los valores del usuario por ejemplo.</p>
<p>Cuando ya tenemos informaciÃ³n de otra fuente, como una base de datos, simplemente llamamos el mÃ©todo <em>DataBind</em>.</p>
<p>El primer parÃ¡metro es una colecciÃ³n <em><a title="IEnumerable Interface" href="http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx" target="_blank">IEnumerable</a></em>, tal como <em><a title="Clase List" href="http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx" target="_blank">List</a></em>. Esta es la razÃ³n por la que no podemos utilizar el objeto <em>DataTable</em> directamente y necesitamos crear un objeto <em><a title="DataView Class" href="http://msdn.microsoft.com/en-us/library/system.data.dataview.aspx" target="_blank">DataView</a></em>.</p>
<p>El segundo parÃ¡metro es el nombre del campo o propiedad para los <em>valores X</em>, y el tercer parÃ¡metro es el campo o propiedad para los <em>valores Y</em>.</p>
<p>Ejecuta el proyecto.</p>
<p><img decoding="async" loading="lazy" title="Ejemplo de Graficas" src="http://blog.oscarscode.com/wp-content/uploads/2011/09/chart-sample.png" alt="Ejemplo de Graficas" width="644" height="471" border="0" /></p>
<p>Por favor deja tus comentarios.</p>The post <a href="http://blog.oscarscode.com/dot-net-es/crear-graficas-en-asp-net/">Crear Graficas en ASP.NET</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></content:encoded>
					
					<wfw:commentRss>http://blog.oscarscode.com/dot-net-es/crear-graficas-en-asp-net/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
		<item>
		<title>Agregar jQuery a una Aplicaci&#243;n Web ASP.NET</title>
		<link>http://blog.oscarscode.com/dot-net-es/agregar-jquery-a-una-aplicacion-web-asp-net/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=agregar-jquery-a-una-aplicacion-web-asp-net</link>
					<comments>http://blog.oscarscode.com/dot-net-es/agregar-jquery-a-una-aplicacion-web-asp-net/#comments</comments>
		
		<dc:creator><![CDATA[Oscar Martinez]]></dc:creator>
		<pubDate>Mon, 01 Aug 2011 13:00:57 +0000</pubDate>
				<category><![CDATA[.NET @es]]></category>
		<category><![CDATA[AJAX @es]]></category>
		<category><![CDATA[ASP.NET @es]]></category>
		<category><![CDATA[jQuery @es]]></category>
		<guid isPermaLink="false">http://blog.oscarscode.com/?p=576</guid>

					<description><![CDATA[<p>jQuery es la librerÃ­a AJAX por default cuando creas una nueva AplicaciÃ³n Web ASP.NET o AplicaciÃ³n Web ASP.NET MVC en Visual Studio 2010. Pero si tienes una aplicaciÃ³n web (Formularios Web) existente, necesitaras agregar manualmente jQuery a tu proyecto. Abre Visual Studio o Visual Web Developer Express y abre una aplicaciÃ³n web. Yo he creado [&#8230;]</p>
The post <a href="http://blog.oscarscode.com/dot-net-es/agregar-jquery-a-una-aplicacion-web-asp-net/">Agregar jQuery a una Aplicación Web ASP.NET</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></description>
										<content:encoded><![CDATA[<p>jQuery es la librerÃ­a AJAX por default cuando creas una nueva <em>AplicaciÃ³n Web ASP.NET</em> o <em>AplicaciÃ³n Web ASP.NET MVC</em> en Visual Studio 2010. Pero si tienes una aplicaciÃ³n web (Formularios Web) existente, necesitaras agregar manualmente jQuery a tu proyecto.</p>
<p>Abre Visual Studio o <a title="Instalar Visual Web Developer Express" href="/?p=401">Visual Web Developer Express</a> y abre una aplicaciÃ³n web. Yo he creado un proyecto nuevo y lo he nombrado <em>jQuerySample</em>.</p>
<p>Si aun no lo tienes, crea una carpeta nueva en tu proyecto (Clic derecho -&gt; Agregar -&gt; Nueva Carpeta) y nÃ³mbrala <em>Scripts</em>.</p>
<p>Descarga jQuery de la <a href="http://docs.jquery.com/Downloading_jQuery#Current_Release" target="_blank">pagina de descarga</a>. La versiÃ³n mas reciente es 1.6.2. Haz clic derecho en el vinculo <em>Minified</em> y elige <em>Guardar Destino Como</em>. Guarda el archivo <em>jquery-1.6.2.min.js</em> en la carpeta <em>Scripts</em>.</p>
<p>Puedes renombrar el archivo a <em>jquery-min.js</em> o <em>jquery.js</em> si prefieres un nombre corto. En este ejemplo yo no lo renombre.</p>
<p>Necesitaras incluir el nuevo archivo en el proyecto. Ve a <em>Proyecto</em> â€“&gt; <em>Ver todos los archivo</em>s o haz clic en el botÃ³n <em>Mostrar todos los archivos</em> en el <em>Explorador de soluciones</em>. Haz clic derecho en el archivo <em>jquery-1.6.2.min.js</em> y selecciona <em>Incluir en el proyecto</em>.</p>
<p>Ahora vamos a habilitar jQuery. Puedes habilitar jQuery en paginas especificas o en todas las paginas si estas utilizando una pagina Maestra (Master page).</p>
<p>Abre el archivo <em>Site.Master</em> y agrega la siguiente etiqueta <em>script</em> dentro de la etiqueta <em>head</em>.</p>
<pre class="brush:html">&lt;head runat="server"&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;link href="~/Styles/Site.css" rel="stylesheet" type="text/css" /&gt;

    &lt;script type="text/javascript" src="&lt;%= ResolveUrl("~/Scripts/jquery-1.6.2.min.js") %&gt;"&gt;&lt;/script&gt;

    &lt;asp:ContentPlaceHolder ID="HeadContent" runat="server"&gt;
    &lt;/asp:ContentPlaceHolder&gt;
&lt;/head&gt;</pre>
<p>Cuando la etiqueta <em>head</em> contiene runat=â€serverâ€, el atributo <em>href</em> de la etiqueta <em>link</em> es automÃ¡ticamente resuelto en tiempo de ejecuciÃ³n, pero el atributo <em>src</em> de la etiqueta <em>script</em> no lo es, asÃ­ que tenemos que utilizar la funciÃ³n <em>ResolveUrl</em>.</p>
<p>Si estas creando un sitio publico, tambiÃ©n podrÃ­as cargar jQuery de la <a title="Google Libraries API" href="http://code.google.com/apis/libraries/">CDN de Google</a> con esta etiqueta.</p>
<pre class="brush:html">&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
<p>Gracias a <a title="3 reasons why you should let Google host jQuery for you" href="http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/" target="_blank">Encosia</a> por este truco. La URL comienza con // para que funcione con http y https.</p>
<p>Vamos a crear un pequeÃ±o ejemplo similar al que creamos cuando <a title="FunciÃ³n $get en ASP.NET AJAX" href="/?p=418">introducimos la funciÃ³n $get</a>.</p>
<p>Agrega un nuevo Formulario Web al proyecto o abre la pagina Default.aspx.</p>
<p>Agrega lo siguiente.</p>
<pre class="brush:html">    &lt;script type="text/javascript"&gt;
        function changeColorAndSize() {
            $('#&lt;%= container.ClientID %&gt;').css("background-color","Red");
            $('#&lt;%= container.ClientID %&gt;').css("height","200px");
            $('#&lt;%= container.ClientID %&gt;').css("width", "300px");
            $('#container2').css("background-color", "Yellow");
            $('#container2').css("height", "200px");
            $('#container2').css("width", "300px");
        }
    &lt;/script&gt;

    &lt;div id="container" runat="server" style="height: 100px; width: 200px; background-color: Blue;"&gt;&lt;/div&gt;
    &lt;div id="container2" style="height: 100px; width: 200px; background-color: Green;"&gt;&lt;/div&gt;
    &lt;asp:Button ID="Button1" runat="server" Text="Click Me" OnClientClick="changeColorAndSize(); return false;" /&gt;</pre>
<p>AquÃ­ mostramos dos elementos <em>div</em>, unos azul y uno verde, y un botÃ³n. Observa como uno de los <em>div</em> es ejecutado en el servidor.</p>
<p>Cuando el botÃ³n es presionado, este llama a la funciÃ³n <em>changeColorAndSize</em>.</p>
<p>La funciÃ³n $() toma un <em>selector CSS</em> y encuentra todos lo elementos que coinciden. En este caso utilizamos # para encontrar el elemento con una ID especifica. Para el div que es ejecutado en el servidor utilizamos la propiedad <em>ClientID</em>.</p>
<p>DespuÃ©s usamos la funciÃ³n <em>css()</em> para cambiar el estilo de un elemento.</p>
<p>Ejecuta el proyecto.</p>
<p><img decoding="async" loading="lazy" title="ASP.NET y jQuery" src="http://blog.oscarscode.com/wp-content/uploads/2011/08/asp-net-jquery-1.png" alt="ASP.NET y jQuery" width="644" height="476" border="0" /></p>
<p>Haz clic en el botÃ³n.</p>
<p><img decoding="async" loading="lazy" title="ASP.NET y jQuery" src="http://blog.oscarscode.com/wp-content/uploads/2011/08/asp-net-jquery-2.png" alt="ASP.NET y jQuery" width="644" height="476" border="0" /></p>
<p>El color y el tamaÃ±o de los elementos <em>div</em> cambiara.</p>
<p>Por favor deja un comentario si tienes alguna pregunta o sugerencia.</p>The post <a href="http://blog.oscarscode.com/dot-net-es/agregar-jquery-a-una-aplicacion-web-asp-net/">Agregar jQuery a una Aplicación Web ASP.NET</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></content:encoded>
					
					<wfw:commentRss>http://blog.oscarscode.com/dot-net-es/agregar-jquery-a-una-aplicacion-web-asp-net/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Add jQuery to an ASP.NET Web Application</title>
		<link>http://blog.oscarscode.com/dot-net/add-jquery-to-an-asp-net-web-application/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=add-jquery-to-an-asp-net-web-application</link>
					<comments>http://blog.oscarscode.com/dot-net/add-jquery-to-an-asp-net-web-application/#comments</comments>
		
		<dc:creator><![CDATA[Oscar Martinez]]></dc:creator>
		<pubDate>Mon, 01 Aug 2011 13:00:02 +0000</pubDate>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[jQuery]]></category>
		<guid isPermaLink="false">http://blog.oscarscode.com/?p=547</guid>

					<description><![CDATA[<p>jQuery is the default AJAX library when you create a new ASP.NET Web Application or ASP.NET MVC Web Application in Visual Studio 2010. But if you have an existing web application (Web Forms), youâ€™ll need to manually add jQuery to your project. Open Visual Studio or Visual Web Developer Express and open your web application. [&#8230;]</p>
The post <a href="http://blog.oscarscode.com/dot-net/add-jquery-to-an-asp-net-web-application/">Add jQuery to an ASP.NET Web Application</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></description>
										<content:encoded><![CDATA[<p>jQuery is the default AJAX library when you create a new <em>ASP.NET Web Application</em> or <em>ASP.NET MVC Web Application</em> in Visual Studio 2010. But if you have an existing web application (Web Forms), youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll need to manually add jQuery to your project.</p>
<p>Open Visual Studio or <a title="Install Visual Web Developer Express" href="/?p=396">Visual Web Developer Express</a> and open your web application.  Iâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ve created a new project named <em>jQuerySample</em>.</p>
<p>If you donâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />t have it yet, create a new folder in your project (Right-click -&gt; Add -&gt; New Folder) and name it <em>Scripts</em>.</p>
<p>Download jQuery from the <a href="http://docs.jquery.com/Downloading_jQuery#Current_Release" target="_blank">download page</a>. Current version is 1.6.2. Right-click on the <em>Minified</em> link and choose <em>Save Target As</em>. Save the <em>jquery-1.6.2.min.js</em> file to the <em>Scripts</em> folder.</p>
<p>You can rename the file to <em>jquery-min.js</em> or just <em>jquery.js</em> if you prefer a short name. I didnâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />t rename it in this sample.</p>
<p>Youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll need to include the new file in the project. Go to <em>Project</em> â€“&gt; <em>View All Files</em> or click on the <em>Show All Files</em> button in the <em>Solution Explorer</em>. Right-click the <em>jquery-1.6.2.min.js</em> file and select <em>Include In Project</em>.</p>
<p>Now letâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s enable jQuery. You could enable jQuery in specific pages or in all pages if youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />re using a Master page.</p>
<p>Open the <em>Site.Master</em> file and add the following <em>script</em> tag inside the <em>head</em> tag.</p>
<pre class="brush:html">&lt;head runat="server"&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;link href="~/Styles/Site.css" rel="stylesheet" type="text/css" /&gt;

    &lt;script type="text/javascript" src="&lt;%= ResolveUrl("~/Scripts/jquery-1.6.2.min.js") %&gt;"&gt;&lt;/script&gt;

    &lt;asp:ContentPlaceHolder ID="HeadContent" runat="server"&gt;
    &lt;/asp:ContentPlaceHolder&gt;
&lt;/head&gt;</pre>
<p>When the <em>head</em> tag runs on the server, the <em>href</em> attribute of the <em>link</em> tag is automatically resolved at runtime, but the <em>src</em> attribute of the <em>script</em> tag is not, so we need to use the <em>ResolveUrl</em> function.</p>
<p>If youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />re creating a public website, you could also load jQuery from <a title="Google Libraries API" href="http://code.google.com/apis/libraries/">Googleâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s CDN</a> with this tag.</p>
<pre class="brush:html">&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
<p>Thanks to <a title="3 reasons why you should let Google host jQuery for you" href="http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/" target="_blank">Encosia</a> for this tip. The URL starts with // so it works with both http and https.</p>
<p>Letâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s create a little sample similar to the one we created when we <a title="ASP.NET AJAX $get function" href="/?p=399">introduced the $get function</a>.</p>
<p>Add a new Web Form to the project or open the Default.aspx page.</p>
<p>Add the following.</p>
<pre class="brush:html">    &lt;script type="text/javascript"&gt;
        function changeColorAndSize() {
            $('#&lt;%= container.ClientID %&gt;').css("background-color","Red");
            $('#&lt;%= container.ClientID %&gt;').css("height","200px");
            $('#&lt;%= container.ClientID %&gt;').css("width", "300px");
            $('#container2').css("background-color", "Yellow");
            $('#container2').css("height", "200px");
            $('#container2').css("width", "300px");
        }
    &lt;/script&gt;

    &lt;div id="container" runat="server" style="height: 100px; width: 200px; background-color: Blue;"&gt;&lt;/div&gt;
    &lt;div id="container2" style="height: 100px; width: 200px; background-color: Green;"&gt;&lt;/div&gt;
    &lt;asp:Button ID="Button1" runat="server" Text="Click Me" OnClientClick="changeColorAndSize(); return false;" /&gt;</pre>
<p>Here, we display two <em>div</em> elements, a blue one and a green one, and a button. Notice how one of the <em>div</em> runs on the server.</p>
<p>When the button is clicked, it calls the <em>changeColorAndSize</em> function.</p>
<p>The $() function takes a <em>CSS selector</em> and finds all elements that match. In this case, we use # to find the element with a specific ID. For the div that run on the server we use the <em>ClientID</em> property.</p>
<p>Then we use the <em>css()</em> function to change an elementâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s style.</p>
<p>Go ahead and run the project.</p>
<p><img decoding="async" loading="lazy" title="ASP.NET and jQuery" src="http://blog.oscarscode.com/wp-content/uploads/2011/08/asp-net-jquery-1.png" alt="ASP.NET and jQuery" width="644" height="476" border="0" /></p>
<p>Click on the button.</p>
<p><img decoding="async" loading="lazy" title="ASP.NET and jQuery" src="http://blog.oscarscode.com/wp-content/uploads/2011/08/asp-net-jquery-2.png" alt="ASP.NET and jQuery" width="644" height="476" border="0" /></p>
<p>The color and size of the two <em>div</em> elements will change.</p>
<p>Please leave a comment if you have a question or suggestion.</p>The post <a href="http://blog.oscarscode.com/dot-net/add-jquery-to-an-asp-net-web-application/">Add jQuery to an ASP.NET Web Application</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></content:encoded>
					
					<wfw:commentRss>http://blog.oscarscode.com/dot-net/add-jquery-to-an-asp-net-web-application/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Una Introducci&#243;n a JavaBeans</title>
		<link>http://blog.oscarscode.com/java-es/una-introduccion-a-javabeans/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=una-introduccion-a-javabeans</link>
					<comments>http://blog.oscarscode.com/java-es/una-introduccion-a-javabeans/#respond</comments>
		
		<dc:creator><![CDATA[Oscar Martinez]]></dc:creator>
		<pubDate>Mon, 18 Jul 2011 13:00:45 +0000</pubDate>
				<category><![CDATA[Java @es]]></category>
		<category><![CDATA[Introduccion]]></category>
		<category><![CDATA[JavaBean @es]]></category>
		<guid isPermaLink="false">http://blog.oscarscode.com/?p=553</guid>

					<description><![CDATA[<p>Antes de examinar herramientas mas avanzadas de JSP, vamos a hablar un poco de lo que son JavaBeans. Un JavaBean, algunas veces llamado simplemente bean, es una clase que cumple con dos reglas muy simples. Incluye un constructor publico sin argumentos, tambiÃ©n conocido como constructor por default. Provee mÃ©todos get, set, e is para las [&#8230;]</p>
The post <a href="http://blog.oscarscode.com/java-es/una-introduccion-a-javabeans/">Una Introducción a JavaBeans</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></description>
										<content:encoded><![CDATA[<p>Antes de examinar herramientas mas avanzadas de <a title="IntroducciÃ³n a JavaServer Pages (JSP)" href="/?p=539">JSP</a>, vamos a hablar un poco de lo que son <em>JavaBeans</em>.</p>
<p>Un JavaBean, algunas veces llamado simplemente <em>bean</em>, es una clase que cumple con dos reglas muy simples.</p>
<ol>
<li>Incluye un constructor publico <em>sin argumentos</em>, tambiÃ©n conocido como <em>constructor por default</em>.</li>
<li>Provee mÃ©todos <em>get</em>, <em>set</em>, e <em>is</em> para las propiedades. El mÃ©todo <em>is</em> es usado en lugar del mÃ©todo <em>get</em> para propiedades booleanas.</li>
</ol>
<p>Eso es todo.</p>
<p>En realidad la Ãºnica regla requerida es tener un constructor sin argumentos, pero una clase sin propiedades no es muy Ãºtil, verdad?</p>
<p>Algunas personas dicen que un JavaBean tambiÃ©n debe de implementar la interfaz S<em>erializable</em>. Esto no es realmente necesario, pero no es una mala idea, ademÃ¡s de que es muy fÃ¡cil de hacer.</p>
<p>Veamos la clase <em>Product</em> de nuestro <a title="IntroducciÃ³n a MVC con Servlets y JSP" href="/?p=546">ejemplo anterior</a>.</p>
<pre class="brush:java">package ServletSample.Business;

public class Product {
    private int id;
    private String name;
    private float price;

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public float getPrice() {
        return price;
    }
    public void setPrice(float price) {
        this.price = price;
    }

    public Product(){
        this.id = -1;
        this.name = "";
        this.price = 0f;
    }

    public Product(int id, String name, float price) {
        this.id = id;
        this.name = name;
        this.price = price;
    }

}</pre>
<p>Esta clase es un JavaBean porque el primer constructor no toma ningÃºn argumento. TambiÃ©n defino mÃ©todos get y set para las propiedades. En este ejemplo, mis propiedades son Id, Name, y Price.</p>
<p><strong>Nota sobre constructores</strong>: Si no defines ningÃºn constructor en tu clase, un constructor sin argumentos es asumido por el compilador. AsÃ­ que tambiÃ©n podrÃ­a definir mi clase asÃ­, y seguirÃ­a siendo considerada un JavaBean.</p>
<pre class="brush:java">package ServletSample.Business;

public class Product implements java.io.Serializable{
    private int id;
    private String name;
    private float price;

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public float getPrice() {
        return price;
    }
    public void setPrice(float price) {
        this.price = price;
    }

}</pre>
<p>Observa que no hay ningÃºn constructor en esta ocasiÃ³n.</p>
<p>TambiÃ©n observa como el JavaBean es ahora serializable. La interfaz <em>Serializable</em> no requiere que implementos ningÃºn mÃ©todo.</p>
<p>En el siguiente post haremos algunas cosas interesantes con JavaBeans.</p>
<p>Por favor deja tu comentario si tienes alguna pregunta.</p>The post <a href="http://blog.oscarscode.com/java-es/una-introduccion-a-javabeans/">Una Introducción a JavaBeans</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></content:encoded>
					
					<wfw:commentRss>http://blog.oscarscode.com/java-es/una-introduccion-a-javabeans/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>An Introduction to JavaBeans</title>
		<link>http://blog.oscarscode.com/java/an-introduction-to-javabeans/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=an-introduction-to-javabeans</link>
					<comments>http://blog.oscarscode.com/java/an-introduction-to-javabeans/#respond</comments>
		
		<dc:creator><![CDATA[Oscar Martinez]]></dc:creator>
		<pubDate>Mon, 18 Jul 2011 13:00:20 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Introduction]]></category>
		<category><![CDATA[JavaBean]]></category>
		<guid isPermaLink="false">http://blog.oscarscode.com/?p=552</guid>

					<description><![CDATA[<p>Before we look into more advanced features of JSP, letâ€™s talk about JavaBeans. A JavaBean, sometimes just called bean, itâ€™s a class that follows two simple rules. Include a public zero-argument constructor, also known as default constructor. Provide get, set, and is methods for properties. The is method is used instead of get for boolean [&#8230;]</p>
The post <a href="http://blog.oscarscode.com/java/an-introduction-to-javabeans/">An Introduction to JavaBeans</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></description>
										<content:encoded><![CDATA[<p>Before we look into more advanced features of <a title="Introduction to JavaServer Pages (JSP)" href="/?p=538">JSP</a>, letâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s talk about <em>JavaBeans</em>.</p>
<p>A JavaBean, sometimes just called <em>bean</em>, itâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s a class that follows two simple rules.</p>
<ol>
<li>Include a public <em>zero-argument</em> constructor, also known as <em>default constructor</em>.</li>
<li>Provide <em>get</em>, <em>set</em>, and <em>is</em> methods for properties. The <em>is</em> method is used instead of <em>get</em> for boolean properties.</li>
</ol>
<p>Thatâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s all.</p>
<p>Really the only required rule is to have a zero-argument constructor, but a class with no properties is not very useful, is it?</p>
<p>Some people say that a JavaBean must also implement the S<em>erializable</em> interface. This is not really necessary, but itâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s not a bad idea, plus itâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s pretty easy to do.</p>
<p>Letâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s take a look at the <em>Product</em> class from our <a title="Introduction to MVC with Servlets and JSP" href="/?p=545">previous sample</a>.</p>
<pre class="brush:java">package ServletSample.Business;

public class Product {
    private int id;
    private String name;
    private float price;

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public float getPrice() {
        return price;
    }
    public void setPrice(float price) {
        this.price = price;
    }

    public Product(){
        this.id = -1;
        this.name = "";
        this.price = 0f;
    }

    public Product(int id, String name, float price) {
        this.id = id;
        this.name = name;
        this.price = price;
    }

}</pre>
<p>This class is a JavaBean because the first constructor doesnâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />t take any arguments. Also, I define get and set methods for the properties. In this example, my properties are Id, Name, and Price.</p>
<p><strong>Note about constructors</strong>: If you donâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />t define any constructor in your class, a default constructor is assumed by the compiler. So I could define my class like this, and it would still be considered a JavaBean.</p>
<pre class="brush:java">package ServletSample.Business;

public class Product implements java.io.Serializable {
    private int id;
    private String name;
    private float price;

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public float getPrice() {
        return price;
    }
    public void setPrice(float price) {
        this.price = price;
    }

}</pre>
<p>Note thereâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s no constructor this time.</p>
<p>Also note how the JavaBean is now serializable. The <em>Serializable</em> interface doesnâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />t require us to implement any method.</p>
<p>In the next post, weâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll do some interesting things with JavaBeans.</p>
<p>Please leave a comment if you have any question.</p>The post <a href="http://blog.oscarscode.com/java/an-introduction-to-javabeans/">An Introduction to JavaBeans</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></content:encoded>
					
					<wfw:commentRss>http://blog.oscarscode.com/java/an-introduction-to-javabeans/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Introducci&#243;n a MVC con Servlets y JSP</title>
		<link>http://blog.oscarscode.com/java-es/introduccion-a-mvc-con-servlets-y-jsp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introduccion-a-mvc-con-servlets-y-jsp</link>
					<comments>http://blog.oscarscode.com/java-es/introduccion-a-mvc-con-servlets-y-jsp/#comments</comments>
		
		<dc:creator><![CDATA[Oscar Martinez]]></dc:creator>
		<pubDate>Tue, 05 Jul 2011 13:00:57 +0000</pubDate>
				<category><![CDATA[Java @es]]></category>
		<category><![CDATA[Introduccion]]></category>
		<category><![CDATA[Java Web @es]]></category>
		<category><![CDATA[JSP @es]]></category>
		<category><![CDATA[MVC @es]]></category>
		<category><![CDATA[Servlet @es]]></category>
		<guid isPermaLink="false">http://blog.oscarscode.com/?p=546</guid>

					<description><![CDATA[<p>Modelo-Vista-Controlador (MVC) es un patrÃ³n usado en ingenierÃ­a de software para separar la lÃ³gica de aplicaciÃ³n de la interfaz de usuario. Como el nombre sugiere, el patrÃ³n MVC tiene tres capas. El modelo define la capa de negocios de la aplicaciÃ³n, la vista define la capa de presentaciÃ³n, y el controlador maneja el flujo de [&#8230;]</p>
The post <a href="http://blog.oscarscode.com/java-es/introduccion-a-mvc-con-servlets-y-jsp/">Introducción a MVC con Servlets y JSP</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></description>
										<content:encoded><![CDATA[<p><em>Modelo-Vista-Controlador</em> (MVC) es un patrÃ³n usado en ingenierÃ­a de software para separar la <em>lÃ³gica de aplicaciÃ³n</em> de la <em>interfaz de usuario</em>.</p>
<p>Como el nombre sugiere, el patrÃ³n MVC tiene tres capas. El <em>modelo</em> define la capa de negocios de la aplicaciÃ³n, la <em>vista</em> define la capa de presentaciÃ³n, y el <em>controlador</em> maneja el flujo de la aplicaciÃ³n.</p>
<p>Aunque el patrÃ³n MVC no es especifico a aplicaciones web, encaja muy bien en este tipo de aplicaciones. En aplicaciones web con Java, el modelo consiste de clases Java simples, la vista consiste de paginas <a title="IntroducciÃ³n a JavaServer Pages (JSP)" href="/?p=539">JSP</a>, y el controlador consiste de <a title="IntroducciÃ³n a Servlets" href="/?p=535">servlets</a>.</p>
<p>Vamos a usar el ejemplo que hemos estado utilizando en los Ãºltimos dos posts. Si deseas crear un nuevo proyecto en <a title="Instalando NetBeans" href="/?p=343">NetBeans</a>, necesitaras las dos clases de los Ãºltimos dos proyectos que representan la capa de negocios.</p>
<p>La primer clase es <em>ServletSample.Business.Product</em>.</p>
<pre class="brush:java">package ServletSample.Business;

public class Product {
    private int id;
    private String name;
    private float price;

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public float getPrice() {
        return price;
    }
    public void setPrice(float price) {
        this.price = price;
    }

    public Product(){
        this.id = -1;
        this.name = "";
        this.price = 0f;
    }

    public Product(int id, String name, float price) {
        this.id = id;
        this.name = name;
        this.price = price;
    }

}</pre>
<p>La segunda clase es <em>ServletSample.Business.ProductService</em>.</p>
<pre class="brush:java">package ServletSample.Business;

import java.util.List;
import java.util.ArrayList;

public class ProductService {

    public List&lt;Product&gt; getProducts(){
        List&lt;Product&gt; products = new ArrayList&lt;Product&gt;();
        products.add(new Product(1,"HP Laptop",799f));
        products.add(new Product(2,"IBM Desktop",599f));
        products.add(new Product(3,"Cannon Printer",159f));
        return products;
    }

    public Product getProduct(int id) {
        Product product = null;
        switch(id)
        {
            case 1:
                product = new Product(1,"HP Laptop",799f);
                break;
            case 2:
                product = new Product(2,"IBM Desktop",599f);
                break;
            case 3:
                product = new Product(3,"Cannon Printer",159f);
                break;
        }
        return product;
    }
}</pre>
<p>Ahora vamos a agregar un servlet al proyecto. Puedes referirte al post donde muestro <a title="IntroducciÃ³n a Servlets" href="/?p=535">como crear un servlet</a> para los pasos correspondientes.</p>
<pre class="brush:java">package ServletSample.Web;

import ServletSample.Business.ProductService;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ProductServlet extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        ProductService service = new ProductService();
        String value = request.getParameter("id");
        if (value != null) {
            int id = Integer.parseInt(value);
            request.setAttribute("single_product", service.getProduct(id));
        } else {
            request.setAttribute("product_list", service.getProducts());
        }
        getServletConfig().getServletContext().getRequestDispatcher("/product.jsp").forward(request,response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

}</pre>
<p>Este servlet es el controlador de nuestra pequeÃ±a aplicaciÃ³n.</p>
<p>Primero trata de leer un parÃ¡metro de la solicitud (request). Dependiendo de si el parÃ¡metro esta presente o no, obtiene uno o todos los productos del modelo (capa de negocios).</p>
<p>Una vez que obtiene los datos necesarios del modelo, guarda esta informaciÃ³n en la solicitud usando el mÃ©todo <em>setAttribute</em>.</p>
<p>Finalmente el controlador <em>redirige</em> la solicitud y la respuesta a una JSP, la vista de la aplicaciÃ³n. Para hacer esto, primero llamamos el mÃ©todo <em>getRequestDispatcher</em> para obtener un objeto <em>RequestDispatcher</em> con la ruta del JSP. DespuÃ©s llamamos el mÃ©todo <em>forward</em> de este objeto.</p>
<p>Si comparas este servlet con el que creamos en nuestro post anterior, notaras cuan mas pequeÃ±o y limpio es el nuevo servlet.</p>
<p>Ahora vamos a crear el JSP. Te puedes referir al post donde mostrÃ© <a title="IntroducciÃ³n a JavaServer Pages (JSP)" href="/?p=539">como crear un JSP</a> para los pasos correspondientes.</p>
<pre class="brush:xml">&lt;%@ page contentType="text/html" pageEncoding="UTF-8"%&gt;

&lt;%@ page import="ServletSample.Business.Product" %&gt;
&lt;%@ page import="ServletSample.Business.ProductService" %&gt;
&lt;%@ page import="java.text.DecimalFormat" %&gt;
&lt;%@ page import="java.util.List" %&gt;

&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"&gt;

&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
        &lt;title&gt;MVC Sample&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;%
        if (request.getAttribute("single_product") != null) {
            Product product = (Product)request.getAttribute("single_product");
        %&gt;

        &lt;h1&gt;Product Details&lt;/h1&gt;
        &lt;div&gt;ID: &lt;%= product.getId()%&gt;&lt;/div&gt;
        &lt;div&gt;Name: &lt;%= product.getName()%&gt;&lt;/div&gt;
        &lt;div&gt;Price: $ &lt;%= new DecimalFormat("#0.00").format(product.getPrice()) %&gt;&lt;/div&gt;
        &lt;div&gt;&lt;a href="product"&gt;Go Back&lt;/a&gt;&lt;/div&gt;

        &lt;% } else { %&gt;

        &lt;h1&gt;Product List&lt;/h1&gt;
        &lt;table&gt;
            &lt;tr&gt;
                    &lt;td&gt;&lt;b&gt;Name&lt;/b&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;b&gt;Options&lt;/b&gt;&lt;/td&gt;
            &lt;/tr&gt;

            &lt;% for (Product product : (List&lt;Product&gt;)request.getAttribute("product_list")) {%&gt;

            &lt;tr&gt;
                &lt;td&gt;&lt;%= product.getName()%&gt;&lt;/td&gt;
                &lt;td&gt;&lt;a href="product?id=&lt;%= product.getId()%&gt;"&gt;Details...&lt;/a&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;% }
          }%&gt;

        &lt;/table&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Este JSP es la vista de la aplicaciÃ³n. Recibe toda la informaciÃ³n que necesita desde el controlador. No necesita llamar a la capa de negocio directamente.</p>
<p>Notaras que este JSP tiene menos cÃ³digo Java que el JSP de nuestro post anterior. Pero aun tenemos un poco de cÃ³digo Java en el JSP. Mostrare las herramientas que JSP tiene para deshacernos completamente de ese cÃ³digo en otro post.</p>
<p>Ejecuta el proyecto. Escribe <em>product</em> en la direcciÃ³n URL. La lista de productos aparecerÃ¡.</p>
<p><img decoding="async" loading="lazy" title="Lista de Productos con MVC" src="http://blog.oscarscode.com/wp-content/uploads/2011/07/product-list-mvc.png" border="0" alt="Lista de Productos con MVC" width="644" height="415" /></p>
<p>Observa como escribimos la direcciÃ³n URL del servlet, nuestro controlador, no la direcciÃ³n del JSP.</p>
<p>Haz clic en uno de los vÃ­nculos.</p>
<p><img decoding="async" loading="lazy" title="Detalles de Producto con MVC" src="http://blog.oscarscode.com/wp-content/uploads/2011/07/product-details-mvc.png" border="0" alt="Detalles de Producto con MVC" width="644" height="415" /></p>
<p>Los detalles del producto se muestran. Haz clic en el vinculo para regresar a la lista de productos.</p>
<p>Por favor deja tus comentarios o sugerencias.</p>The post <a href="http://blog.oscarscode.com/java-es/introduccion-a-mvc-con-servlets-y-jsp/">Introducción a MVC con Servlets y JSP</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></content:encoded>
					
					<wfw:commentRss>http://blog.oscarscode.com/java-es/introduccion-a-mvc-con-servlets-y-jsp/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Introduction to MVC with Servlets and JSP</title>
		<link>http://blog.oscarscode.com/java/introduction-to-mvc-with-servlets-and-jsp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introduction-to-mvc-with-servlets-and-jsp</link>
					<comments>http://blog.oscarscode.com/java/introduction-to-mvc-with-servlets-and-jsp/#respond</comments>
		
		<dc:creator><![CDATA[Oscar Martinez]]></dc:creator>
		<pubDate>Tue, 05 Jul 2011 13:00:39 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Introduction]]></category>
		<category><![CDATA[Java Web]]></category>
		<category><![CDATA[JSP]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Servlet]]></category>
		<guid isPermaLink="false">http://blog.oscarscode.com/?p=545</guid>

					<description><![CDATA[<p>Model-View-Controller (MVC) is a pattern used in software engineering to separate the application logic from the user interface. As the name implies, the MVC pattern has three layers. The model defines the business layer of the application, the view defines the presentation layer of the application, and the controller manages the flow of the application. [&#8230;]</p>
The post <a href="http://blog.oscarscode.com/java/introduction-to-mvc-with-servlets-and-jsp/">Introduction to MVC with Servlets and JSP</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></description>
										<content:encoded><![CDATA[<p><em>Model-View-Controller</em> (MVC) is a <em>pattern</em> used in software engineering to separate the <em>application logic</em> from the <em>user interface</em>.</p>
<p>As the name implies, the MVC pattern has three layers. The <em>model</em> defines the business layer of the application, the <em>view</em> defines the presentation layer of the application, and the <em>controller</em> manages the flow of the application.</p>
<p>Although the MVC pattern is not specific to web applications, it fits very well in this type of applications. In web applications with Java, the model consists of simple Java classes, the view consists of <a title="Introduction to JavaServer Pages (JSP)" href="/?p=538">JSP</a> pages, and the controller consists of <a title="Introduction to Servlets" href="/?p=504">servlets</a>.</p>
<p>Letâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s use the sample weâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ve been working on for the last two posts. If you want to create a new project in <a title="Installing NetBeans" href="/?p=119">NetBeans</a>, youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll need the two classes from the last two projects that represent the business layer.</p>
<p>The first class is <em>ServletSample.Business.Product</em>.</p>
<pre class="brush:java">package ServletSample.Business;

public class Product {
    private int id;
    private String name;
    private float price;

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public float getPrice() {
        return price;
    }
    public void setPrice(float price) {
        this.price = price;
    }

    public Product(){
        this.id = -1;
        this.name = "";
        this.price = 0f;
    }

    public Product(int id, String name, float price) {
        this.id = id;
        this.name = name;
        this.price = price;
    }

}</pre>
<p>The second class is <em>ServletSample.Business.ProductService</em>.</p>
<pre class="brush:java">package ServletSample.Business;

import java.util.List;
import java.util.ArrayList;

public class ProductService {

    public List&lt;Product&gt; getProducts(){
        List&lt;Product&gt; products = new ArrayList&lt;Product&gt;();
        products.add(new Product(1,"HP Laptop",799f));
        products.add(new Product(2,"IBM Desktop",599f));
        products.add(new Product(3,"Cannon Printer",159f));
        return products;
    }

    public Product getProduct(int id) {
        Product product = null;
        switch(id)
        {
            case 1:
                product = new Product(1,"HP Laptop",799f);
                break;
            case 2:
                product = new Product(2,"IBM Desktop",599f);
                break;
            case 3:
                product = new Product(3,"Cannon Printer",159f);
                break;
        }
        return product;
    }
}</pre>
<p>Now letâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s add a servlet to the project. You can refer to the post where I showed <a title="Introduction to Servlets" href="/?p=504">how to create a servlet</a> for the corresponding steps.</p>
<pre class="brush:java">package ServletSample.Web;

import ServletSample.Business.ProductService;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ProductServlet extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        ProductService service = new ProductService();
        String value = request.getParameter("id");
        if (value != null) {
            int id = Integer.parseInt(value);
            request.setAttribute("single_product", service.getProduct(id));
        } else {
            request.setAttribute("product_list", service.getProducts());
        }
        getServletConfig().getServletContext().getRequestDispatcher("/product.jsp").forward(request,response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

}</pre>
<p>This servlet is the controller of our little application.</p>
<p>First, it tries to read a parameter from the request. Depending on if thereâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s a parameter or not, it gets a product or all of the products from the model (business layer).</p>
<p>Once it retrieved the necessary data from the model, it saves this data in the request using the <em>setAttribute</em> method.</p>
<p>Finally, the controller <em>forwards</em> the request and response objects to a JSP, the view of the application. To do this, we first call the <em>getRequestDispatcher</em> method to get a <em>RequestDispatcher</em> object with the path of the JSP. Then we call the <em>forward</em> method of this object.</p>
<p>If you compare this servlet with the one we created in our previous post, youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll notice how much smaller and cleaner the new servlet is.</p>
<p>Now letâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s create the JSP. You can refer to the post where I showed <a title="Introduction to JavaServer Pages (JSP)" href="/?p=538">how to create a JSP</a> for the corresponding steps.</p>
<pre class="brush:xml">&lt;%@ page contentType="text/html" pageEncoding="UTF-8"%&gt;

&lt;%@ page import="ServletSample.Business.Product" %&gt;
&lt;%@ page import="ServletSample.Business.ProductService" %&gt;
&lt;%@ page import="java.text.DecimalFormat" %&gt;
&lt;%@ page import="java.util.List" %&gt;

&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"&gt;

&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
        &lt;title&gt;MVC Sample&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;%
        if (request.getAttribute("single_product") != null) {
            Product product = (Product)request.getAttribute("single_product");
        %&gt;

        &lt;h1&gt;Product Details&lt;/h1&gt;
        &lt;div&gt;ID: &lt;%= product.getId()%&gt;&lt;/div&gt;
        &lt;div&gt;Name: &lt;%= product.getName()%&gt;&lt;/div&gt;
        &lt;div&gt;Price: $ &lt;%= new DecimalFormat("#0.00").format(product.getPrice()) %&gt;&lt;/div&gt;
        &lt;div&gt;&lt;a href="product"&gt;Go Back&lt;/a&gt;&lt;/div&gt;

        &lt;% } else { %&gt;

        &lt;h1&gt;Product List&lt;/h1&gt;
        &lt;table&gt;
            &lt;tr&gt;
                    &lt;td&gt;&lt;b&gt;Name&lt;/b&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;b&gt;Options&lt;/b&gt;&lt;/td&gt;
            &lt;/tr&gt;

            &lt;% for (Product product : (List&lt;Product&gt;)request.getAttribute("product_list")) {%&gt;

            &lt;tr&gt;
                &lt;td&gt;&lt;%= product.getName()%&gt;&lt;/td&gt;
                &lt;td&gt;&lt;a href="product?id=&lt;%= product.getId()%&gt;"&gt;Details...&lt;/a&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;% }
          }%&gt;

        &lt;/table&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>This JSP is the view of the application. It receives all the information it needs from the controller. It doesnâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />t need to call the business layer directly.</p>
<p>Youâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll notice that this JSP has less Java code than the JSP from our previous post. But thereâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />s still some Java code in the JSP. Iâ€<img src="https://s.w.org/images/core/emoji/14.0.0/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" />ll show you the tools JSP has to get rid of that code in another post.</p>
<p>Go ahead and run the project. Type <em>product</em> in the URL. The Product List will appear.</p>
<p><img decoding="async" loading="lazy" title="Product List With MVC" src="http://blog.oscarscode.com/wp-content/uploads/2011/07/product-list-mvc.png" border="0" alt="Product List With MVC" width="644" height="415" /></p>
<p>Notice how we type the URL of the servlet, our controller, not the URL of the JSP.</p>
<p>Click on one of the links.</p>
<p><img decoding="async" loading="lazy" title="Product Details With MVC" src="http://blog.oscarscode.com/wp-content/uploads/2011/07/product-details-mvc.png" border="0" alt="Product Details With MVC" width="644" height="415" /></p>
<p>The product details are shown. Click on the link to go back to the product list.</p>
<p>Please leave your comments or suggestions.</p>The post <a href="http://blog.oscarscode.com/java/introduction-to-mvc-with-servlets-and-jsp/">Introduction to MVC with Servlets and JSP</a> first appeared on <a href="http://blog.oscarscode.com">Oscar's Code</a>.]]></content:encoded>
					
					<wfw:commentRss>http://blog.oscarscode.com/java/introduction-to-mvc-with-servlets-and-jsp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin


Served from: blog.oscarscode.com @ 2026-05-31 05:33:13 by W3 Total Cache
-->