aspose file tools*
The moose likes JSP and the fly likes Run time checkbox values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Run time checkbox values" Watch "Run time checkbox values" New topic
Author

Run time checkbox values

Rush Shah
Greenhorn

Joined: Oct 16, 2010
Posts: 6
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





Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rush Shah
Greenhorn

Joined: Oct 16, 2010
Posts: 6


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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

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

Joined: Oct 16, 2010
Posts: 6
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.


Prashant Dasari
Greenhorn

Joined: Oct 28, 2010
Posts: 6
JSP code:



Servlet code:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Run time checkbox values