Search This Blog

Follow by Email

Saturday, September 5, 2015

struts multibox example

Struts multibox [multiple check boxes] example

1. create a memeber variables and respective setters and getters in any form class like below

import org.apache.struts.action.ActionForm;
   public class LanguageForm extends ActionForm
    private String[] selectedLanguages = {}; 
 private String[] languages = {"Java","J2EE","JSP","STRUTS","Spring"}; 
 public String[] getSelectedLanguages() {
  return selectedLanguages;

 public void setSelectedLanguages(String[] selectedLanguages) {
  this.selectedLanguages = selectedLanguages;

 public String[] getLanguages() {
  return languages;

 public void setLanguages(String[] languages) {
  this.languages = languages;

2. Add below code inside action class to display languages in JSP

public class LanguageAction extends Action {
 private static final String SUCCESS = "success";

 public ActionForward execute(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response)
   throws Exception {
          String selectedLanguageValues="";
    LanguageForm languageForm = (LanguageForm)form;
   for (String selectedLanguage : languageForm.getSelectedLanguages()) {
    selectedLanguageValues = selectedLanguageValues.concat(selectedLanguage+",");
   if(selectedLanguageValues != null && !selectedLanguageValues.isEmpty()){
    selectedLanguageValues = selectedLanguageValues.substring(0,selectedLanguageValues.length()-1);
   return SUCCESS;

3. JSP code as mentioned below

<%@taglib uri="" prefix="html"%>
         <%@taglib uri="" prefix="bean"%>
         <%@taglib uri="" prefix="logic"%>



4. Need to do respective configuratio in struts-config.xml like action class, form class etc...
Refer Struts Step By Step example in this blog for configuration related details.


  1. This post is really useful and helpful to know more about the Advance java and jsp, which you have shared . I appreciate you for such a great amount of information. I assure this would be beneficial for many people. Best Advance java classes in jaipur

  2. Your blog have very good information regarding the java, I also have some worth information regarding the java course, I think this info will be very helpful for you. Best Data Structures With Java Course In Delhi



Contact Form


Email *

Message *