• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Run time checkbox values

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

Is it possible to set the runtime values for the check box.
I am trying with below code but instead of printing the runtime value of variable i ,it prints
{i}

what is wrong in the code?





below code change gives compiler error


code for getting the output





 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using out.println() is a JSP make no sense at all. Just put the HTML in template text. In fact, you shouldn't be using any Java code in the JSP at all.

EL expressions in Java statements will not be evaluated.
 
Rush Shah
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


thanks for the reply.

I wants to create the dynamic checkbox , if I am using the servlet also for above code
will not work since it's a java code.

Then we can't create dynamic check box?how should we dynamically set the value for checkbox ?

Is it possible or not ?

 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are doing this in a servlet, you can't use any JSP mechanisms such as the EL.

Why would you not be using a JSP for the view?

I assumed that this code was in a JSP because you posted in the JSP forum.
 
Rush Shah
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is my requirement and number of answers are dynamically varies i.e for some question
2 answer so on the ui screen chk box1 --- answer1,chk box 2 ---answer2 should display ,
for some question 3 answer so on the ui screen chk box1 --- answer1,chk box 2 ---answer2, chk box 3 ---answer3 should display

so to satisfy above requirement i need to display the check box dynamically.

for(int i=0;i<questionList.size();i++)
{
out.println("<td><input type='checkbox' name='id' value='${i}'> </td>");
out.println(questionList.get(i));
out.println("<br>");
}
using this loop in jsp i need outputp like this

i
1 checkbox1 answer1
2 checkbox2 answer2
3 checkbox3 answer3

here 1,2,3 are the value of variable i

using the above code i am able to get the below output but value of variable i is missing.

checkbox1 answer1
checkbox2 answer2
checkbox3 answer3


so please help me out how to achive this solution.


 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP code:



Servlet code:

 
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic