Archive | Struts

get session into action class in struts 2.x

Nov 25th, 2011No Comments

JSPs contain implicit session object to use in the jsp pages, when an action in invoked in struts we need to get ‘session ‘ into the action class, we can do this by implementing “SessionAware” interface. Eclipse  will ask you to implement an unimplemented  method click on that meesage and eclipse will create the method for you called “public void setSession(Map<String, Object> arg0){//TODO}”

(more…)

VN:F [1.9.10_1130]
Rating: 8.3/10 (4 votes cast)
VN:F [1.9.10_1130]
Rating: 0 (from 0 votes)

Hello World program in Struts 2.0

May 28th, 2011No Comments
Hello World Application

Here we will see how to create a simpe Struts 2 Hello World Application. The following files are needed to create a Hello World Application.

  • web.xml
  • struts.xml
  • HelloWorld.java
  • index.jsp
  • success.jsp

(more…)

VN:F [1.9.10_1130]
Rating: 9.0/10 (3 votes cast)
VN:F [1.9.10_1130]
Rating: +2 (from 2 votes)

Using JavaScript to submit a form in Struts

May 22nd, 2011No Comments

You can submit a form with a link as below. the examples below assume you are in an <html:form> block and ‘myForm’ is picked up from the struts-config.xml name field of the action.

<a href=’javascript:void(document.forms["myForm"].submit()>My Link</a>

Now the trick in the action is to decode what action you intend to perform. Since you are using JavaScript, you could set a field value and look for it in the request or in the form.

(more…)

VN:F [1.9.10_1130]
Rating: 10.0/10 (3 votes cast)
VN:F [1.9.10_1130]
Rating: +4 (from 4 votes)