# 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/anchor/

## 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 <title> 08 index.jsp 09 </title> 10 </head> 11 <body> 12 <jsp:include page="/resources/jsp/header.jsp"/> <br/> 13 <h3>Anchor Tag Sample</h3> 14 <blockquote> 15 <p> 16 <b>Linking to a Page</b><br> 17 This netui:anchor tag links to the page "linkPage.jsp":<br> 18 <netui:anchor href="linkPage.jsp">To linkPage.jsp</netui:anchor> 19 20 <hr> 21 <b>Invoking an Action Method</b><br> 22 This netui:anchor tag invokes the action method "showCurrentTime".<br> 23 <netui:anchor action="showCurrentTime">Invoke showCurrentTime</netui:anchor> 24 25 <hr> 26 <b>Submitting Form Data</b><br> 27 This netui:anchor tag submit data to the "formSubmit" action.<br> 28 <netui:form action="formSubmit"> 29 Firstname: 30 <netui:textBox dataSource="{actionForm.firstname}"/><br> 31 Lastname: 32 <netui:textBox dataSource="{actionForm.lastname}"/><br> 33 <netui:anchor formSubmit="true">Submit</netui:anchor> 34 </netui:form> 35 36 <hr> 37 <b>Submitting Form Data with a Custom Java Script Function</b><br> 38 This netui:anchor tag invokes the custom JavaScript method "helloAlert" before submitting the data.<br> 39 <netui:form action="formSubmit"> 40 Firstname: 41 <netui:textBox dataSource="{actionForm.firstname}"/><br> 42 Lastname: 43 <netui:textBox dataSource="{actionForm.lastname}"/><br> 44 <netui:anchor formSubmit="true" onClick="SubmitFromAnchor();return false;">Submit</netui:anchor> 45 </netui:form> 46 <script language="JavaScript" type="text/JavaScript"> 47 function SubmitFromAnchor() 48 { 49 // Place custom logic here... 50 alert("Hello, " + document.forms[1].elements[0].value + " " + document.forms[1].elements[1].value + "!"); 51 52 for(var i=0; i<document.forms.length; i++) 53 { 54 // submit to the action formSubmit 55 if (document.forms[i].action == "/WebApp/tagSamples/netui/anchor/formSubmit.do") 56 { 57 document.forms[i].method="POST"; 58 document.forms[i].action="/WebApp/tagSamples/netui/anchor/formSubmit.do"; 59 document.forms[i].submit(); 60 } 61 } 62 } 63 </script> 64 </p> 65 </blockquote> 66 <hr> 67 <netui:anchor href="/WebApp/tagSamples/tagSamplesController.jpf">Return to Tag Samples</netui:anchor> 68 </body> 69 </netui:html>`