• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

calling action while loading the home page

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And your problem is?
 
abheeshek reddy
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks

My problem is ....My action is not called.

I am not sure what is happening, No error messages in console or logs..
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic