# Index.jsp Sample

This topic inludes the source code for the Index.jsp Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/rewrite/

## Sample Source Code

`01 <%@ page language="java" contentType="text/html;charset=UTF-8"%> 02 <%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%> 03 <%@ taglib uri="netui-tags-html.tld" prefix="netui"%> 04 <%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%> 05 <netui:html> 06 <head> 07 <netui:base/> 08 <title> 09 Rewrite Samples 10 </title> 11 <link href="../../../resources/css/style.css" type="text/css" rel="stylesheet"/> 12 </head> 13 <body> 14 15 <jsp:include page="/resources/jsp/header.jsp"/> <br/> 16 17 <blockquote> 18 19 <h3>Rewrite Samples</h3> 20 21 <p>This sample shows how the &lt;netui:rewriteName> 22 and &lt;netui:rewriteURL> tags can be used in JSP pages, 23 enabling applications such as Portals to rewrite names or URLs 24 so that the Portlet instances have unique identifiers. </p> 25 26 <hr width="90%"> 27 28 <p>Please refer to the pre-rendered 29 /rewrite/index.jsp source code. In this page, we create a Javascript method 30 using the &lt;netui:rewriteName> tag and put the result into the 31 <code>pageContext</code>. This would allow a portal application 32 (if one was using this JSP page) to qualify the name, by referring 33 to the resultId, which has the value "realName". This page also 34 demonstrates creating the name and then using it in other parts of 35 the page, as seen in this next link.</p> 36 37 <script type="text/javascript"> 38 <!-- 39 function <netui:rewriteName name="myFunction" resultId="realName"/>(anchor) 40 { 41 anchor.style.color = "red"; 42 } 43 function <%= pageContext.getAttribute("realName")%>Out(anchor) 44 { 45 anchor.style.color = "blue"; 46 } 47 --> 48 </script> 49 50 <p> 51 <netui:anchor onMouseOver='<%= pageContext.getAttribute("realName") + "(this);"%>' 52 action="begin" onMouseOut='<%= pageContext.getAttribute("realName") 53 + "Out(this);"%>'>Notice how this sample link changes color 54 onMouseOver and onMouseOut.</netui:anchor> </p> 55 56 <p>Refer to the pre-rendered JSP code to see how the 57 &lt;netui:rewriteName> tag was used to declare a "realName" resultId.</p> 58 59 <hr width="90%"> 60 61 <p>In this next example, both the &lt;netui:rewriteName> and &lt;netui:rewriteURL 62 tags are shown being used in standard HTML lt;span> and &lt;image> tags (that is, not in 63 other NetUI tags). This would allow a portal to qualify the URL and Id attributes. 64 </p> 65 66 <span id="<netui:rewriteName name="foo"/>" style="color:red"> 67 This is text inside a span tag set, which gets its Id from a &lt;netui:rewriteName> 68 tag's attribute. 69 </span> 70 <br/> 71 <p>The following images are displayed via standard &lt;image> tags, which use 72 <code>src</code> attributes that contain the &lt;netui:rewriteURL> tag.</p> 73 <p> <img src="<netui:rewriteURL URL="../../../resources/images/weblogic-img-rt.gif"/>"></p> 74 <p> <img src="<netui:rewriteURL URL="../../../resources/images/bar-background.gif"/>"></p> 75 76 </blockquote> 77 78 <hr> 79 <netui:anchor href="/WebApp/tagSamples/tagSamplesController.jpf">Return to Tag Samples</netui:anchor> 80 </body> 81 </netui:html>`