I have an application in which i have to load a set values while loading the page itself.
below is the code i wrote
welcome.jsp
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<script>
function getAction(){
alert('inside getAction');
var i = document.forms[0].action="/getAction.do";
alert(i);
document.forms[0].action=request.getContextPath+"/getAction";
document.forms[0].submit();
}
</script>
<html:html locale="true">
<head>
<title><bean:message key="welcome.title"/></title>
<html:base/>
</head>
<body bgcolor="white" onLod="getAction()">
<html:form action="/getAction">
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%" >
<tr>
<%@ include file="top.jsp"%>
</tr>
<tr>
<td VALIGN=TOP WIDTH="17%">
<table BORDER=2 CELLSPACING=0 CELLPADDING=0 WIDTH="137" BGCOLOR="WHITE" >
<tr>
<td HEIGHT="2"> </td>
</tr>
<tr ALIGN=LEFT>
</tr>
<tr ALIGN=LEFT>
<td><a href="advantage.htm" ><CENTER>
JDBC</CENTER></a></td>
</tr>
<tr>
<html:submit/>
</tr>
<tr ALIGN=LEFT>
<td><a href="students.htm" ><CENTER>
SERVLETS</CENTER></a></td>
</tr>
<tr ALIGN=LEFT>
<td><a href="curriculum.htm" ><CENTER>
JSP</CENTER></a></td>
</tr>
<tr ALIGN=LEFT>
<td><a href="faculty.htm" ><CENTER>
STRUTS</CENTER></a></td>
</tr>
<tr ALIGN=LEFT>
<td><a href="visitors.htm" ><CENTER>SPRING</CENTER></a></td>
</tr>
<tr ALIGN=LEFT>
<td HEIGHT="7"><a href="press.htm" ><CENTER>HIBERNATE</CENTER></a></td>
</tr>
<tr ALIGN=LEFT>
<td HEIGHT="23"><a href="contact.htm" ><CENTER>
EJB</CENTER></a></td>
</tr>
<tr ALIGN=LEFT>
<td HEIGHT="23"> </td>
</tr>
</table>
</td>
<td valign="top">Here is the space for insertion create a table and insert
</td>
</tr>
<logic:notPresent name="org.apache.struts.action.MESSAGE" scope="application">
<font color="red">
ERROR: Application resources not loaded -- check servlet container
logs for error messages.
</font>
</logic:notPresent>
<h3><bean:message key="welcome.heading"/></h3>
<tr>
<center><%@ include file="./footer.jsp"%></center>
</tr>
</table>
</html:form>
</body>
</html:html>
Struts-config.xml
<action
path="/getAction"
name="TopicListForm"
scope="session"
input="/pages/Welcome.jsp"
type="roseindia.web.struts.action.TopicListAction">
<forward name="success" path="/pages/Welcome.jsp"/>
</action>
<form-bean name="TopicListForm"
type="roseindia.web.struts.form.TopicListForm">
</form-bean>
project is my root folder.
pages and web-inf are sub-folders
welcome.jsp is in pages folder