Advertisement

08.21.2007 at 08:12PM PDT, ID: 22778519
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Multiple Same-Named Checkboxes in JSP?
Tags: jsp, checkbox, multiple
Hello,
I have a form with multiple checkbox items (for easy deletes from the table), the checkboxes are all named "check", but each have different values assigned to them (corresponding to db id's), I also have a checkall checkbox, whcih as expected when checked checks all, or when unchecked, unchecks all the checkboxes. When i submit the form I only get one value for check instead of a comma delimited list of values.... what am I doing wrong?

Here is my form:

                        <table border=1 cellpadding=0 cellspacing=0 width=80%>
                            <form action="manager.jsp" method=post name="frmMain" id="frmMain">
                            <input type=hidden name="where" value="">
                            <th><input type=checkbox name=selectall onclick="checkall(this.form)"></th><th>Campaign Name</th><th>Status</th><th>List Size</th>
                           
                                <tr>
                                    <td width=25px align=center valign=center><input type=checkbox value="7" name="check"> </td><td> test7 </td><td> In Queue. </td><td>92763</td>

                               </tr>
                           
                                <tr>
                                    <td width=25px align=center valign=center><input type=checkbox value="6" name="check"> </td><td> test6 </td><td> In Queue. </td><td>92763</td>
                               </tr>
                           
                                <tr>
                                    <td width=25px align=center valign=center><input type=checkbox value="5" name="check"> </td><td> test5 </td><td> In Queue. </td><td>92763</td>

                               </tr>
                           
                                <tr>
                                    <td width=25px align=center valign=center><input type=checkbox value="4" name="check"> </td><td> test4 </td><td> In Queue. </td><td>92763</td>
                               </tr>
                           
                            <tr><td bgcolor="red" colspan=4 align=right valign=center><input type="button" value="Delete" onClick="formSubmit('deletejob');"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="New" onClick="formSubmit('newjob');"/></form></td></tr>
                        </table>



Then when I try to output all the check values:

C: ${param.check}<br>

it outputs:

C: 7

instead of:

C: 7,6,5,4


What am I doing wrong? How do I  make this work properly?

Worth 500 points.

Thanks,
Rick
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: richardsimnett
Solution Provided By: cezarF
Participating Experts: 2
Solution Grade: A
Views: 135
Translate:
Loading Advertisement...
08.21.2007 at 08:30PM PDT, ID: 19743409

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.21.2007 at 08:57PM PDT, ID: 19743539

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.21.2007 at 10:03PM PDT, ID: 19743746

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.21.2007 at 10:24PM PDT, ID: 19743810

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.21.2007 at 10:46PM PDT, ID: 19743887

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.22.2007 at 12:18AM PDT, ID: 19744154

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.22.2007 at 06:10PM PDT, ID: 19750849

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.22.2007 at 08:15PM PDT, ID: 19751348

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.22.2007 at 09:10PM PDT, ID: 19751534

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.23.2007 at 08:25AM PDT, ID: 19755184

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.23.2007 at 09:17AM PDT, ID: 19755689

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
08.21.2007 at 08:30PM PDT, ID: 19743409
try to include a hidden input textbox to your page to store the checkbox values separated by comma. call a javascript function before submitting similar to this

var txt = ""
for (i = 0; i < document.myform.check.length; i++) {
      if (document.myform.check.[i].checked) {
            if (txt=="")
                  txt = document.myform.check[i].value
            else
                  txt += ("," + document.myform.check[i].value)
      }
}
document.myform.checkboxValues.value = txt;

then read the value of the textbox instead of the checkboxes.

hope it helps.

Accepted Solution
 
08.21.2007 at 08:57PM PDT, ID: 19743539

Rank: Wizard

Please try it this way.
<c:forEach items="${paramValues.check}" var="checkedBox" >
   ${checkedBox}
</c:forEach>
 
08.21.2007 at 10:03PM PDT, ID: 19743746
rrz,
I got no output from your comment.

Thanks,
Rick
 
08.21.2007 at 10:24PM PDT, ID: 19743810

Rank: Wizard

>I got no output from your comment.
I tested it before I posted. It works.
param and paramValues are EL variables. paramValues returns a String array.
 
08.21.2007 at 10:46PM PDT, ID: 19743887
@richard:thanks!
 
08.22.2007 at 12:18AM PDT, ID: 19744154
rrz,
hmmm.....

what version of tomcat are you using? I am using 5.5.1 with Netbeans, and its not outputting anything at all. Just blanks.

Thanks,
Rick
 
08.22.2007 at 06:10PM PDT, ID: 19750849

Rank: Wizard

>what version of tomcat are you using?  
I am using Tomcat 6, but it doesn't matter.
>and its not outputting anything at all. Just blanks
Are you sure that the parameters are being sent ? Did you test with simple form with a submit button ?
What does
${paramValues.check}
print ?  It should display something like   [Ljava.lang.String;@1ff92f5   (meaning the array is available)
 
08.22.2007 at 08:15PM PDT, ID: 19751348
still nothing...

here is my code and PV Check comes up blank all the time... I also have another strange problem in this chunk of code, for some reason two variables (tame & clicommand) never get initialized for my usage in EL, but I can access them using <%= variablename%>. Here's my code maybe the issues are related:

<c:when test="${where == 'savejob'}">
                    PV Check: ${paramValues.check}<br>
                    <tags:fileUpload path="/home/rick/pvw/web/fileUploads/"/>
                    <% String jobname = request.getAttribute("jobname").toString();%>
                    <% String filename = request.getAttribute("filename").toString();%>
                    <% String tame = request.getAttribute("filename_no_path").toString();%>
                   
                    Filename: ${filename} | ${tame} | <%= tame%><br>
                   
                    <tags:lineCounter filename="${filename}"/>
                    <% String linecount = request.getAttribute("linecount").toString();%>
                 
                    Importing File: sh /home/rick/pvw/bash/mysql_import.sh ${filename}  ${tame}<br><br>
                   
                    <% String clicom = "sh /home/rick/pvw/bash/mysql_import.sh" + filename + " " + tame;%>
                   
                    CLI Command: ${clicom}<br>
                   
                    <tags:execCLI cli="${clicom}"/>
                   
                    <%-- insert the new job into the database --%>
                    <sql:setDataSource var="insjob" url="jdbc:mysql://192.168.1.4/pdev" driver="com.mysql.jdbc.Driver" user="pdev" password="pdev2k7"/>
                    <sql:update var="insJob" dataSource="${insjob}">
                        INSERT INTO jobs (jobname,listcount,listname)
                        VALUES ('${jobname}',${linecount},'listname');
                    </sql:update>
                   
                     <jsp:include page="viewjobs.jsp"/>
                </c:when>




This code causes this error because ${clicom} evaluates to nothing for some reason when its output, and when its passed to the execCLI tag.




HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /manager.jsp:61

58:                    
59:                     CLI Command: ${clicom}<br>
60:                    
61:                     <tags:execCLI cli="${clicom}"/>
62:                    
63:                     <%-- insert the new job into the database --%>
64:                     <sql:setDataSource var="insjob" url="jdbc:mysql://192.168.1.4/pdev" driver="com.mysql.jdbc.Driver" user="pdev" password="pdev2k7"/>


Stacktrace:
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: Empty command
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:854)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
      org.apache.jsp.manager_jsp._jspService(manager_jsp.java:295)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
 
08.22.2007 at 09:10PM PDT, ID: 19751534

Rank: Wizard

>never get initialized for my usage in EL, but I can access them using <%= variablename%>.  
EL can access scoped variables but not scripting variables.
 
08.23.2007 at 08:25AM PDT, ID: 19755184
ok... what does that mean exactly?

 
08.23.2007 at 09:17AM PDT, ID: 19755689

Rank: Wizard

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
  String scriptVar = "scripting variable";
%>
<c:set var="tag" value="set by tag"/>
Scoped variable is ${tag} or by a setAttribute method.<br/>
Unscoped variable is a<%=scriptVar%>.<br/>
?${scriptVar} No, I can't see that.<br/>
<c:set var="scoped" value="<%=scriptVar%>"/>
Now, I can see the scoped ${scoped}.
 
 
20080236-EE-VQP-29 / EE_QW_1_20070628