Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML
Struts
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
Static Parameter
In this section, we will develop a simple application to access the static parameter.
 
 

Static Parameter

                         

In this section, we will develop a simple application to access the static parameters. We will use a JavaBean to set and get the static parameters. Each static parameter has a value.  

Description :

Develop a JavaBean with three properties (Static Parameters) of string type ( parameter1,parameter2, parameter3 ). Define three JavaBean properties and add their corresponding values in the action mapping (in the application's struts.xml ). Set the name(s) and value(s) as shown below:

code snippet from
struts.xml
 

<action name="StaticParameter" class="net.roseindia.StaticParameter">
    <param name="pramater1">Value 1</param>
    <param name="pramater2">Value 2</param>
    <param name="pramater3">Value 3</param>
    <result>/pages/staticparameter/showparamerts.jsp</result>
</action>

Create a simple JavaBean StaticParameter.java in the "struts2tutorial\WEB-INF\src\java\net\roseindia" directory. Here  the "StaticParameter" class extends the ActionSupport class. It sets and gets the three static parameters by using the setParameter1(), setParameter2(), setParameter3() and getParameter1(), getParameter2(), getParameter3() methods. 

Now compile the JavaBean (StaticParameter.java) through the 'ant' command. 

StaticParameter.java

package net.roseindia;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Date;

public  class StaticParameter  extends ActionSupport {

  private String pramater1;
  private String pramater2;
  private String pramater3;
  
    public String execute() throws Exception {
      return SUCCESS;
  }

  public String getPramater1() {
    return pramater1;
  }

  public void setPramater1(String pramater1) {
    this.pramater1 = pramater1;
  }

  public String getPramater2() {
    return pramater2;
  }

  public void setPramater2(String pramater2) {
    this.pramater2 = pramater2;
  }

  public String getPramater3() {
    return pramater3;
  }

  public void setPramater3(String pramater3) {
    this.pramater3 = pramater3;
  }

}

Create a jsp page (showparameters.jsp) to view the static parameters.  

showparameters.jsp

<%taglib prefix="s" uri="/struts-tags" %>
<html>
    <head>
        <title>Static Parameter Example!</title>
    </head>
    <body>
    <h1>Static Parameter</h1>
    <table border="1" width="25%" bgcolor="#ffffcc">
       <tr>
      <td width="25%"><b>Key</b></td>
      <td width="25%"><b>Value</b></td>
      </tr>
      <tr>
      <td width="25%">pramater1</td>
      <td width="25%"><s:property value="pramater1" /></td>
      </tr>
      <tr>
      <td width="25%">pramater2</td>
      <td width="25%"><s:property value="pramater2" /></td>
      </tr>
      <tr>
      <td width="25%">pramater3</td>
      <td width="25%"><s:property value="pramater3" /></td>
      </tr>
    </table>
    </body>
</html>

Open web browser and give request as http://localhost:8080/struts2tutorial/roseindia/StaticParameter.action. It displays a table that contains three static parameters in key-value format.

Output of this application:

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Tutorials:
Styles in HTML
Style Tags Used in HTM
Check Box in HTML
Action Submit Html
Cascading Style Sheet(
Horizontal Rule Attrib
Horizontal Rule in HTM
Show Hyperlink in HTML
Unordered Lists
Paragraph in HTML
Password Field in HTML
Radio Buttons in HTML
Set Background Colors
Table & the Border att
Text Area in HTML
Text Field in HTML
Use of Text Field
Table Caption in HTM
J2ME Servlet Example
J2ME Cookies Example
J2ME Frame Animation2
J2ME Frame Animation
J2ME RMS Read Write
J2ME Record Data Base
J2ME Audio Record
J2ME Record Listener
J2ME Text Box Example
J2ME Timer Animation
J2ME Vector Example
J2ME Video Control Exa
J2ME Event Handling Ex
J2ME HashTable Example
J2ME Icon MIDlet Examp
J2ME Image Item Exampl
J2ME Image Example
J2ME Item State Listen
J2ME Key Codes Example
J2ME KeyEvent Example
J2ME Label Example
J2ME Random Number
J2ME Read File
J2ME RMS Sorting Examp
J2ME Timer MIDlet Exam
Custom Item in J2ME
Creational Design Patt
Design Patterns
Throwing Run time exce
Grid in Echo3
Creating Table in Echo
JPA Introduction
Java bigdecimal toBigI
Java bigdecimal shortV
Java bigdecimal shortV
Java bigdecimal signum
Java bigdecimal stripT
Java bigdecimal subtra
Java bigdecimal subtra
Java bigdecimal toBigI
Java bigdecimal toEngi
Java bigdecimal toPlai
Java bigdecimal toStri
Java bigdecimal ulp ex
Java bigdecimal unscal
Java bigdecimal valueO
Java bigdecimal valueO
Java bigdecimal valueO
Java bigdecimal setSca
Java bigdecimal setSca
Java bigdecimal scaleB
Java bigdecimal scale
Java bigdecimal round
Java bigdecimal remain
Java bigdecimal remain
Java bigdecimal precis
Java bigdecimal pow me
Java bigdecimal pow ex
Java bigdecimal plus m
Java bigdecimal plus e
Java bigdecimal negate
Java bigdecimal negate
Java bigdecimal multip
Java bigdecimal multip
Java BigDecimal movePo
Java bigdecimal movePo
Java bigdecimal min ex
Java bigdecimal max ex
CheckBox component in
Visibility of Componen
Loading delay componen
Simple input applicati
Opening a new window i
Hello World in Echo3 f
Use of Local Inner cla
JSP bean set property
Java Method Synchroniz
Java Method Return Val
JAVA Method Wait
JDBC vs ORM
Java BigDecimal divide
Java BigDecimal divide
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.