arrays - how to use arraylist to display questions using jsp -


i creating website using jsp, servlet, dbao(jdbc) , database in eclispe j2ee, , feature survey questions. not sure how create arraylist in jsp page store questions in database, when there new question not need hardcode question. result want able display questions using arraylist in jsp page. how should that?

if understand correctly, have, or want create database questions survey. want dynamically populate web page these questions. there several ways so. i'll talk 2 of them, question broad, not full implementation, conceptual explanation. have learn more seperate libraries , elements mention. in both cases, data formed on server side, sent client, , parsed , displayed on client side.

1. javabeans , jstl

if survey questions defined string only, no other attributes needed (like type of question, possible set of valid multiple choice answers, etc) can define arraylist<string>, , send through httprequest/response of java servlet. if questions objects of multiple fields, reason, need define javabean class, , create collection of instances. in html, import jstl core, , use for:each-tag iterate through of elements in arraylist, , if javabean-objects, elements attributes.

2. ajax, json , javascript (jquery)

you can retrieve data populate domain object model, after tag-elements loaded. in case, can send ajax request servlet, in turn should return formatted response. reccommend json this. then, in ajax function on client side, need parse response, , use javascript/jquery format , populate survey container element.

this might seem little overwhelming, there many ways of communicating between client side , server side, , without specifications of method use (or want use) hard give specific response.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -