Trying to call my stringbuffer class in my JSP.

I'm trying to call a class (using StringBuffer for the html) in my jsp but can't seem to get the form objects (textbox, listmenu, checkbox) to display on the jsp.  I can display the text on the form (the form questions) the questions are coming from the database but not the html tags (form objects, table tags, etc).  The jsp is listed below.  Keep in mind the StringBuffer has all the html so that's why the jsp doesn't have html tags.

<%@page import="servlet.FormServlet"%>

     
     
   <%
      List Formquest = (List)request.getAttribute("Formquest ");
      Iterator it = Formquest.iterator();
      FormQuestions formInfo = null;
      String fquestion;
      String fobject;
      while (it.hasNext())
             {
               formInfo = (FormQuestions)it.next();
               fquestion = formInfo.getFormquest();
               fobject = formInfo.getType();
    %>
                <%= fquestion  %><BR><BR>
           <%= fobject %><BR><BR>

       <%
 
       if (fobject.equals("textfield")){
       %>
          <input name="<%= question %>" type="text">
         
       <%
       }
       if (fobject.equals("textarea ")){
       %>
         
       <%
       }
   
       if (fobject.equals("dropdown ")){
       %>
         
       <%
    }
   
 
   
    %>
 
   
 <%
   }
   %>
   
javabeginrAsked:
Who is Participating?
 
patbinConnect With a Mentor Commented:
can u paste some part of ur servlet
0
 
objectsCommented:
whats the value of fobject?
0
 
patbinCommented:
first check that ur resulset is ok if it is ok then try this

<%@page import="servlet.FormServlet"%>

     
     
   <%
     List Formquest = (List)request.getAttribute("Formquest ");
     Iterator it = Formquest.iterator();
     FormQuestions formInfo = null;
     String fquestion;
     String fobject;
     while (it.hasNext())
             {
               formInfo = (FormQuestions)it.next();
               fquestion = formInfo.getFormquest();
               fobject = formInfo.getType();
    %>
               <%= fquestion  %><BR><BR>
          <%= fobject %><BR><BR>

       <%
 
       if (fobject.equals("textfield")){
     
      out.println("<input name=' question ' type='text'>);
       
             }
       if (fobject.equals("textarea ")){
similarly here also      
 }
   
       if (fobject.equals("dropdown ")){
       %>
         
       <%
    }
   
 
   
    %>
 
   
 <%
   }
   %>
hope this will solve ur problem
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
javabeginrAuthor Commented:
Nope doesn't work.  

Objects - the value of fobject is the form objects textfield, textarea, and menu/list.  

Can somebody please give me a solution?
0
 
searlasCommented:
You need to show more of your JSP.  You mentioned something about StringBuffer, but there's no StringBuffer in the code you provide.

Also, it looks like you declare a variable called 'fquestion', but you also use 'question' in your scriptlet:
<input name="<%= question %>" type="text">

Where's this 'question' variable defined?

Show us the whole JSP and give us a chance to show you a solution.

0
 
javabeginrAuthor Commented:
Sorry but I'm not sure how to explain what I'm trying to do to you guys.  I mean I'm trying to build dynamic forms.  What I mean by this is I want to display the html tags dynamically from the servlet.  I have the string buffer on my servlet but I'm not sure how to call it to display the tags on my jsp.  The question variable is defined in the servlet (I changed it to object1 it makes more sense).  I'm displaying the questions from my database but not able to display the html form objects from my servlet using a stringbuffer.  My question is what am I doing wrong in my jsp why isn't the form objects showing? How do I call the stringbuffer to display the form objects?

<%@page import="servlet.FormServlet"%>

     
     
   <%
     List Formquest = (List)request.getAttribute("Formquest ");
     Iterator it = Formquest.iterator();
     FormQuestions formInfo = null;
     String fquestion;
     String fobject;
     while (it.hasNext())
             {
               formInfo = (FormQuestions)it.next();
               fquestion = formInfo.getFormquest();
               fobject = formInfo.getType();
    %>
               <%= fquestion  %><BR><BR>
          <%= fobject %><BR><BR>

       <%
 
       if (fobject.equals("textfield")){
       %>
          <input name="<%= object1 %>" type="text">
         
       <%
       }
     
   
    %>
 
   
 <%
   }
   %>




0
 
javabeginrAuthor Commented:
Also this is all of the jsp because again I'm trying to bring in the html tags dynamically from the servlet.  
0
 
objectsCommented:
Can you post the generated html please
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.