Array of Fields in JSP page

hi,
i am just a biginer in java forum& application developement,
*********problem****************
I am using jsp+struts2 combination. one of my jsp page contains a select field to select number (n).
on basis of that selected number(n) I've to display n text fields.for every text field there is an submit button.
how it is possible? using arry index?

Yes, you can use the array notation in the name of the input element. You should end up with something like:
<table>
    <tr><td><input name="input[0]"></td></tr>
    <tr><td><input name="input[1]"></td></tr>
    <tr><td><input name="input[2]"></td></tr>
</table>
<input type="hidden" name="rows" value="3">You can use JSTL c:forEach with a varStatus for this.

Similar Messages

  • Capturing LOV Return Item in a field of JSP Page

    Dear Members,4
    I am using JDev 10g (10.1.3.5.0)
    Requirement: I want to display a LOV for a field which is not bound to data model. To achieve this requirement I have follwed the below steps.
    Steps:-
    I have a simple JSP page in which there is a select input text field which is as follows:-
    *<af:selectInputText label="Label 1" action="dialog:Test1" windowHeight="500" windowWidth="400"*
    id="label1"/>
    I have created the necessary navigation rules to Test1 page and also the required VO for the respective LOV.
    From this Label 1 field I am able to go to the Test1 page which is a LOV Page and I am displaying the LOV records. After selecting a record, I want to come back to my main JSP Page and the selected value should appear in the field Label 1. I am not able to return the selected LOV value to the Label 1._
    The code I am using to return the value from the LOV Page is as follows:-
    public void returnObject(ActionEvent actionEvent)
    JUCtrlValueBindingRef selectedRowData = (JUCtrlValueBindingRef)getTable1().getSelectedRowData();
    if(selectedRowData==null)
    AdfFacesContext.getCurrentInstance().returnFromDialog(null, null);
    return ;
    assetCat = (String)selectedRowData.getRow().getAttribute("Name");
    AdfFacesContext.getCurrentInstance().returnFromDialog(this,null);
    Note: I want to return the assetCat value to the Label 1 field.
    Can any one please help me in resolving this issue.
    Many thanks in advance.
    Reards,
    R4S

    Hello,
    Many thanks for your reply.
    I am new to ADF. Can you please elaborate your solution.
    Regards,
    R4S

  • Help with Jtext fields on JSP page?

    Hi All,
    How can I collect an integer on a JSP page from user input?
    I am looking to vallidate the user input also thought about vallidating using HTML then passing/casting the input to a Java variable for further manipulation on the page.
    I cannot use response.encodeUrl for this.
    Effectively what I would like to do is replicate what a JTextField with an action listener would do to retrieve user input in a desktop Java application.
    Any ideas and help would be welcome.
    regards
    Jim Ascroft

    Hi All ,
    I propbably didnt put my questions all that well.
    So I wil try to be more specific.
    1.How can I collect an integer on a JSP page from user input?
    I am looking to vallidate the user input. I thought about vallidating using HTML then passing/casting the input to a Java variable for further manipulation on the page.
    I cannot use response.encodeUrl for this.
    2.I understand that my Java helper classes are compiled into .class files and then used by the JSP page as required. Also the Java code within the <% %> Java tags is recognised and runs .
    So if the java between the <% %> tags can be compiled and used why can other Java components eg Swing or AWT not be used in the same way?
    Effectively what I would like to do is replicate what a JTextField with an action listener would do to retrieve user input in a desktop Java application.
    Any ideas and help would be welcome.
    regards
    Jim Ascroft

  • Dates in JSP page

    I have some dates fields on JSP page I want to store data in mysql databse. Can someone tell me how I can format dates as I do for other data types in servlet before I send data to add in databse: such as
    For int type data:
    String paymentID = request.getParameter("PaymentID")
    I format it like this for class Payment.
    Payment newPayment(int.parseInt(paymentID)               
    how do i work with date fields this is what I Am trying to do:
    Code patches....
    import java.text.DateFormat;\import java.text.ParseException;
    public date date1;
    try                               
          date1= format.parse(paymentStartDate);
    catch(ParseException pe)
    System.out.println("Problem found");
    ....I do not get any error but it leaves date fields empty because date1 formatting never goes to try... Always say "Problem found on console"
    Any help?

    I just realized I should post the whole file... here is code of the servlet that recieved dates from JSP and process it.
    package admin;
    import java.lang.Object.*;
    import java.text.DateFormat;
    import java.util.Date;
    import java.io.IOException;
    import java.text.ParseException;
    import data.*;
    import business.*;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class AddPaymentServlet extends HttpServlet{
         public Date date1;
         public Date date2;
        public DateFormat format;
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
    // Stores user entered Payment information in variables to create new Payment vector
              String paymentID = request.getParameter("paymentID");
              String clientName = request.getParameter("clientName");
             String paymentType = request.getParameter("paymentType");
              String paymentAmount = request.getParameter("paymentAmount");
             String paymentStartDate = request.getParameter("paymentStartDate");
              String paymentExpiryDate = request.getParameter("paymentExpiryDate");
              String paymentDescription = request.getParameter("paymentDescription");
              String paymentState1 = request.getParameter("paymentState"); // use String type of PaymentType
    //-----------------------------------Format dates----------------------------------------------------------          
             DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.SHORT);
           //    System.out.println("Date1--->"+date1);
                  try
                       {    date1 = format.parse(paymentStartDate);
                        //    System.out.println("Date1--->"+date1);
                     catch(ParseException ps)
                            System.out.println("can't format dates");     
                      try
                       date2 = format.parse(paymentExpiryDate);
                  catch(ParseException pe)
                       System.out.println("can't format dates");
    // get old Payment object from session
    //--------------------------------Send new PAyment Information to Vector Payment in Payment.jave-----------------------------
              Payment newPayment = new Payment(clientName,paymentType,Double.parseDouble(paymentAmount),date1,date2,paymentDescription,paymentState1);
    //------------------------------ Call PaymentDB function Add() to store new payment infomration in the databse
             PaymentDB.addRecord(newPayment);
    // over-write Payment object in session
              request.getSession().setAttribute("payment",newPayment);
              request.getSession().setAttribute("payments",PaymentDB.readRecords());
    //---------------------------------- Send results back to payment.jsp for updated information----------------------
              RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/Admin/payments.jsp");
              dispatcher.forward(request, response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
              doGet(request, response);
    }

  • Checkbox on a JSP page

    hi experts
    is there any control for Boolean field in JSP??
    how can bind boolean field in JSP page??
    waiting for help
    Thanks

    Surely, someone must have tried to put a checkbox on a JSP page and bind it to data?
    All suggestions are welcome.
    tnx
    -Jan

  • Forwarding array of String to jsp

    Hi all
    I want to forward an array of string to jsp page. I use the following code:
    servlet:
    request.setAttribute("list", list);and
    jsp:
    <%  String[] symptomslist = (String[])request.getAttribute("symptomslist"); %>But the values in the array are null. The length is correct. Can anyone please help me in this?
    Thanks a lot.
    dude

    Hey Hey,
    Sorry,
    My code was suppose to be this:
    String[] list = (String[])request.getAttribute("list");Thanks for noticing. Can anyone still help me?
    dude

  • Using an Array in a JSP page

    I am currently storing values from a database into an array
    im my servlet. I have a JSP page and I'm trying to set
    the datafields on this page to the values held in the array.
    I need to send the array from the servlet to the JSP page
    and then figure out how I retrieve it at the other end.
    Can anyone help????????

    Here's the code I'm using for my Sevlet:
    package SASSSpkg;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    import javax.swing.*;
    public class UserLogin extends HttpServlet{
         private Connection connection;
    private ResultSet resultSet;
         private Statement statement;
         public String getusername, getpassword, getdatabase;
         private String customerId;     
         private String title;
         private String firstName;
         private String secondName;
         private String surname;
         private String residentialAddress;
         private String dateOfBirth;
         private String correspondenceName;
         private String maritalStatus;
         private String gender;
         private String securityId;
         private String postCode;
         private String dateOfFirstContact;
         private String homeTel;
         private String businessTel;
         private String currentAddressEntryDate;
         private String nationalInsuranceNumber;
         private String dateLastUpdated;
         public ArrayList values = new ArrayList();
         public void init(ServletConfig config) throws ServletException
              super.init(config);
         public UserLogin()
         public void ConnectToDatabase() throws Exception
    String url = "jdbc:odbc:SASSS";
    String username = getusername;
    String password = getpassword;
    // Load the driver to allow connection to the database
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = DriverManager.getConnection( url, username,
    password);
    catch (ClassNotFoundException cnfex)
    throw new Exception("cannot connect to database");
    catch (SQLException sqlex)
    throw new Exception("cannot connect to database");
    public void getResultSetData()
    try
    String query = "SELECT DISTINCT CUSTOMER_ID, TITLE, FORENAME1, FORENAME2, SURNAME, DATE_OF_BIRTH, CUSTOMER_SALUTATN, MARITAL_STATUS, GENDER, SECURITY_NAME, FIRST_CONTACT_DATE,POSTCODE, TELEX, DATE_AT_ADDRESS, NATIONAL_INS_NUM, ADDRESS.LAST_UPDATED, ADDRESS.TELEPHONE FROM CUSTOMER, ADDRESS, CUSTOMER_ADDRESS WHERE CUSTOMER.CUSTOMER_CODE = CUSTOMER_ADDRESS.CUSTOMER_CODE AND CUSTOMER_ADDRESS.ADDRESS_ID = ADDRESS.ADDRESS_ID";
    statement = connection.createStatement
    (ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);                
    resultSet = statement.executeQuery(query);
    resultSet.first();
         for (int i = 0; i <= 16; i ++)
              values.add(resultSet.getString(i + 1));
              statement.close();          
    catch(SQLException sqlex)
    sqlex.printStackTrace();
         public void doPost(HttpServletRequest req, HttpServletResponse
    res)
              throws ServletException, IOException
         try{
                   boolean dbConnection;
                   // Get username and password from fields on web
    page
                   getusername = req.getParameter("UserName");
                   getpassword = req.getParameter("Password");
                   getdatabase = req.getParameter("Database");
                   PrintWriter output = res.getWriter();
                   res.setContentType("text/html");
                   if(getusername.equals("") || getpassword.equals
                   res.sendRedirect
    ("http://localhost:9080/SASSS/ErrorPage.jsp");
                   return;
                   else
                        ConnectToDatabase();
                        getResultSetData();
                        res.sendRedirect
    ("http://localhost:9080/SASSS/EmployeeDetails.jsp");
              catch(Exception ex) {
                   res.sendRedirect
    ("http://localhost:9080/SASSS/ErrorPage.jsp");          
         public void doGet(HttpServletRequest req, HttpServletResponse
    resp)
              throws ServletException, IOException
              req.setAttribute("myArrayList", values);
         public String getCustomerId()
              return customerId;
         public void setCustomerId(String Id)
              customerId = Id;
         public String getTitle()
              return title;
         public void setTitle(String theTitle)
              title = theTitle;;
         public String getFirstName()
              return firstName;
         public void setFirstName(String theFirstName)
              firstName = theFirstName;
         public String getSecondName()
              return secondName;
         public void setSecondName(String theSecondName)
              secondName = theSecondName;
         public String getSurname()
              return surname;
         public void setSurname(String theSurname)
              surname = theSurname;
         public String getResidentialAddress()
              return residentialAddress;
         public void setResidentialAddress(String theResidentialAddress)
              residentialAddress = theResidentialAddress;
         public String getDob()
              return dateOfBirth;
         public void setDob(String theDOB)
              dateOfBirth = theDOB;
         public String getCorrespondenceName()
              return correspondenceName;
         public void setCorrespondenceName(String theCorrespondenceName)
              correspondenceName = theCorrespondenceName;
         public String getMaritalStatus()
              return maritalStatus;
         public void setMaritalStatus(String theMaritalStatus)
              maritalStatus = theMaritalStatus;
         public String getGender()
              return gender;
         public void setGender(String theGender)
              gender = theGender;
         public String getSecurityId()
              return securityId;
         public void setSecurityId(String theSecurityId)
              securityId = theSecurityId;
         public String getPostCode()
              return postCode;
         public void setPostCode(String thePostCode)
              postCode = thePostCode;
         public String getDateOfFirstContact()
              return dateOfFirstContact;
         public void setDateOfFirstContact(String theDateOfFirstContact)
              dateOfFirstContact = theDateOfFirstContact;
         public String getHomeTel()
              return homeTel;
         public void setHomeTel(String theHomeTel)
              homeTel = theHomeTel;
         public String getBusinessTel()
              return businessTel;
         public void setBusinessTel(String theBusinessTel)
              businessTel = theBusinessTel;
         public String getCurrentAddressEntryDate()
              return currentAddressEntryDate;
         public void setCurrentAddressEntryDate(String
    theCurrentAddressEntryDate)
              currentAddressEntryDate = theCurrentAddressEntryDate;
         public String getNationalInsuranceNumber()
              return nationalInsuranceNumber;
         public void setNationalInsuranceNumber(String
    theNationalInsuranceNumber)
              nationalInsuranceNumber = theNationalInsuranceNumber;
         public String getDateLastUpdated()
              return dateLastUpdated;
         public void setDateLastUpdated(String theDateLastUpdated)
              dateLastUpdated = theDateLastUpdated;
    Here's the code I'm using for my JSP:
    <HEAD><SCRIPT type="text/javascript">
    <!--
    var _sstmrID = null;
    var _sstmrON = false;
    var _sspos   = 80;
    function _ScrollStatus(msg, delay)
    if (_sstmrON)
    window.clearTimeout(_sstmrID);
    _sstmrON = false;
    var statmsg = "";
    if (_sspos >= 0)
    for (s = 0; s < _sspos; s++)
    statmsg += " ";
    statmsg += msg;
    else
    statmsg = msg.substring(-_sspos, msg.length);
    window.status = statmsg;
    sspos = (-sspos > msg.length) ? 80 : _sspos - 1;
    fname = "_ScrollStatus('" + msg + "', " + delay + ")";
    _sstmrID = window.setTimeout(fname, delay);
    _sstmrON = true;
    //-->
    </SCRIPT><SCRIPT type="text/javascript">
    <!--
    function _ShowObj(lId)
    var ob;ob=new Array;
    var appVer=parseInt(navigator.appVersion);
    var isNC=false,isN6=false,isIE=false;
    if (document.all && appVer >= 4) isIE=true; else
    if (document.getElementById && appVer > 4) isN6=true; else
    if (document.layers && appVer >= 4) isNC=true;
    if (isNC)
    w_str = "document." + lId;ob[lId] = eval(w_str);
    if (!ob[lId]) ob[lId] = _FindHiddenObj(document, lId);
    if (ob[lId]) ob[lId].visibility = "show";
    if (isN6)
    ob[lId] = document.getElementById(lId);
    ob[lId].style.visibility = "visible";
    if (isIE)
    w_str = "document.all.item(\"" + lId + "\").style";ob[lId] = eval(w_str);
    ob[lId].visibility = "visible";
    function _FindHiddenObj(doc, lId)
    for (var i=0; i < doc.layers.length; i++)
    var w_str = "doc.layers.document." + lId;
    var obj;obj=new Array;
    obj[lId] = eval(w_str);
    if (!obj[lId]) obj[lId] = _FindHiddenObj(doc.layers[i], lId);
    if (obj[lId]) return obj[lId];
    return null;
    //-->
    </SCRIPT></HEAD>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <html:html>
    <HEAD>
    <%@ page
    language="java"
    contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    errorPage="ErrorPage.jsp"
    %>
    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <META name="GENERATOR" content="IBM WebSphere Studio">
    <META http-equiv="Content-Style-Type" content="text/css">
    <LINK href="style.css" rel="stylesheet" type="text/css">
    <h2>
    <%@page import="SASSSpkg.UserLogin"%>
    <%@page import="java.util.*"%>
    <%@page import="javax.servlet.*"%>
    <%@page import="javax.servlet.http.*"%>
    <% UserLogin ul = new UserLogin(); %>
    <TITLE>SASSS Employee Details</TITLE>
    </HEAD>
    <BODY bgcolor="#c0c0c0"><FORM action="servlet/SASSSpkg.UserLogin" method="get">
    <%
    if (request.getAttribute("myArrayList") != null) {
    ArrayList Alist = (ArrayList)request.getAttribute("myArrayList");
    ul.setCustomerId(Alist.get(0).toString());
    else {
    response.sendRedirect("http://localhost:9080/SASSS/ErrorPage.jsp");
    %>
    <TABLE border="0" width="792" height="359">
         <TBODY>
              <TR>
                   <TD colspan="6" valign="middle" align="center" height="58"><B>Customer
                   Id</B> <INPUT type="text" name="customerId" size="20" maxlength="10"
                        disabled value='<%= ul.getCustomerId() %>'></TD>
              </TR>
              <TR>
                   <TD align="center" height="57" width="160"><SPAN
                        style="font-weight: bold"><B>Title</B><BR>
                   <SELECT name="title" size="1">
                             <OPTION><%= ul.getTitle()%></OPTION>
                             <OPTION>Mr</OPTION>
                             <OPTION>Mrs</OPTION>
                             <OPTION>Miss</OPTION>          
                   </SELECT></SPAN></TD>
                   <TD align="left" height="57" width="171"><SPAN
                        style="font-weight: bold"><B><STRONG>First Name</STRONG></B><BR>
                   <SCRIPT type="text/javascript">
    <!--
    _ScrollStatus("How cool is this", 2);
    //-->
    </SCRIPT><INPUT type="text" name="firstName" size="20" maxlength="25" value = '<%= ul.getFirstName() %>' ></SPAN></TD>
                   <TD align="left" height="57" colspan="2"><SPAN
                        style="font-weight: bold"><B>Second Name</B><BR>
                   <INPUT type="text" name="secondName" size="20" maxlength="25" value='<%= ul.getSecondName() %>'></SPAN></TD>
                   <TD align="left" height="57" colspan="2"><SPAN
                        style="font-weight: bold">Surname<BR>
                   <INPUT type="text" name="surname" size="20" maxlength="25" value='<%= ul.getSurname() %>'> </SPAN></TD>
              </TR>
              <TR>
                   <TD colspan="2" align="center" rowspan="3"><B>Residential Address</B><BR>
                   <TEXTAREA rows="7" cols="31" name="residentialAddress" ><%= ul.getResidentialAddress() %></TEXTAREA></TD>
                   <TD align="left" height="66" colspan="2"><B>Date of Birth</B><BR>
                   <INPUT type="text" name="dateOfBirth" size="20" maxlength="10" value='<%= ul.getDob() %>'></TD>
                   <TD align="left" colspan="2"><B>Correspondence Name<BR>
                   <INPUT type="text" name="correspondenceName" size="20" maxlength="25" value='<%= ul.getCorrespondenceName() %>'>
                   </B></TD>
              </TR>
              <TR>
                   <TD align="left" height="42" colspan="2"><B>Marital Status </B> <SELECT
                        name="maritalStatus" style="">
                        <OPTION selected><%= ul.getMaritalStatus()%></OPTION>
                        <OPTION>Divorced</OPTION>
                        <OPTION>Married</OPTION>
                        <OPTION>Seperated</OPTION>
                        <OPTION>Single</OPTION>
                        <OPTION>Widowed</OPTION>
                   </SELECT></TD>
                   <TD align="left" colspan="2"><B>Gender</B> <SELECT name="gender">
                        <OPTION><%= ul.getGender()%></OPTION>
                        <OPTION>Female</OPTION>
                        <OPTION>Male</OPTION>
                   </SELECT></TD>
              </TR>
              <TR>
                   <TD colspan="4" height="56"><B>Security
                   Id     </B><INPUT type="text" name="securityId"
                        size="20" maxlength="20" value='<%= ul.getSecurityId() %>'></TD>
              </TR>
              <TR>
                   <TD height="55" align="left" colspan="2" nowrap><B>
                      Post Code   </B> <INPUT type="text"
                        size="15" maxlength="8" value='<%= ul.getPostCode() %>' name="postCode"></TD>
                   <TD height="55" align="left" colspan="2"><B>Date of First Contact</B><BR>
                   <INPUT type="text" name="dateOfFirstContact" size="10" maxlength="10" value='<%= ul.getDateOfFirstContact() %>'>
                   </TD>
                   <TD height="55" rowspan="5" align="center" colspan="2"><SELECT
                        size="9" name="aditionalDetailForms">
                        <OPTION value="">Products Held</OPTION>
                        <OPTION>Employment</OPTION>
                        <OPTION>Dependants</OPTION>
                        <OPTION>Residential Details</OPTION>
                        <OPTION>Assets/Liabilities</OPTION>
                        <OPTION>Income/Commitments</OPTION>
                        <OPTION>Banks/Building Societies</OPTION>
                        <OPTION>Credit Cards</OPTION>
                        <OPTION>Leads and Follow ups</OPTION>
                        <OPTION value=""></OPTION>
                   </SELECT></TD>
              </TR>
              <TR>
                   <TD height="41" align="left" colspan="2" nowrap><B>   Home
                   Tel                         </B>
                   <INPUT type="text" name="homeTel" size="18" maxlength="14" value='<%= ul.getHomeTel() %>'></TD>
                   <TD height="41" align="left" colspan="2"><INPUT type="button"
                        name="lastAddress" value="Last Address"></TD>
              </TR>
              <TR>
                   <TD height="49" align="left" colspan="2" nowrap><B>   Business
                   Tel                  </B>
                   <INPUT type="text" name="businessTel" size="18" maxlength="14" value='<%= ul.getBusinessTel() %>'></TD>
                   <TD height="49" align="left" valign="bottom" colspan="2"><B>N.I.
                   Number</B></TD>
              </TR>
              <TR>
                   <TD height="42" colspan="2" nowrap><B>   Current
                   Address Entry Date  </B> <INPUT
                        type="text" name="currentAddressEntryDate" size="10" maxlength="10" value='<%= ul.getCurrentAddressEntryDate() %>'></TD>
                   <TD height="42" colspan="2"><INPUT type="text"
                        name="nationalInsuranceNumber" size="20" maxlength="9" value='<%= ul.getNationalInsuranceNumber() %>'></TD>
              </TR>
              <TR>
                   <TD height="44" colspan="2" nowrap><B>   Date Last
                   Updated                   </B>
                   <INPUT type="text" name="dateLastUpdated" size="10" maxlength="15" value='<%= ul.getDateLastUpdated() %>'></TD>
                   <TD height="44" align="left" colspan="2"><INPUT type="button"
                        name="directMailExclusions" value="Mail Exclu">    <INPUT
                        type="button" name="telephoneExclusions" value="Tel Exclu"></TD>
              </TR>
              <TR>
                   <TD height="44" align="left" colspan="6" nowrap>        <INPUT
                        type="submit" name="ok" value=" OK ">            <INPUT
                        type="button" name="forward" value=" >> ">            <INPUT
                        type="button" name="exit" value=" Exit ">            <INPUT
                        type="button" name="delete" value=" Delete ">            <INPUT
                        type="reset" name="refresh" value=" Refresh ">            <INPUT
                        type="button" name="help" value=" Help "></TD></TR>
    </TABLE></FORM>
    </BODY>
    </html:html>
    The problem is, I'm trying to store String values into an array,
    or a result set and then store them in the data fields on my jsp page.
    When I use my set method such as setCustomerId(values.get(0));
    it sets the variable customerId to the value I want but when I try to
    call the get method in the JSP page to assign it to the data field it
    will not retrieve it.
    Can anyone solve this, I've been at it for days now????

  • Why my JSP page can't get the value of a hidden field

    Hi, I got an interesting question here.
    I use req.getParameter() method to get a hidden field in Servlet, it works just fine.
    However, when I use the JSP to catch the value of that hidden field, JSP just can't, but if I change the type from hidden to text, it works fine again.
    the code is as follows:
    there are two jsp pages:game.jsp and GameMonitor.jsp.
    In game page:
    ============================================================
    <FORM action=GameMonitor.jsp method=post
    webbot-action="--WEBBOT-SELF--">Display the names of all the players currently
    connected to the server       <INPUT tabIndex=1 type=submit value=Lookup name=B1>
    <INPUT TYPE=hidden,value=1 name=p1>
    <P></P></FORM>
    ===========================================================
    I want GameMonitor.jsp to catch the value of hidden field "p1" by calling request.getParameter()
    the code catching it in the GameMonitor.jsp is:
    ============================================================
    String option = request.getParameter("p1");
              out.println("option=["+option+"]");
              try{
                   if(option.equals("1")){
    ===========================================================
    supurisingly, the result is option=[], which means it didn't catch the value of the p1 submitted by POST method.
    Does anybody here can tell what's wrong in the code?

    Thank you so much, I also found this error, which makes JSP not able to catch the hidden field, however, if I change it to text type, even the comma exists, it still works. pretty interesting!
    >
    <INPUT TYPE=hidden,value=1 name=p1>Modify the above lline and write like this....
    <INPUT TYPE="hidden" name="p1" value="1">
    And ensure that you're submitting the form data.
    Though nothing much has been changed, just try whether
    these help!!!
    fun_one

  • How to insert a date picker input text field in a JSF Jsp page

    Hi,
    I have to develop an application using generic facets, unfortunately I am not supposed to use ADF Faces components given by Oracle.
    Now my requirement is, on JSP page an input text field which holds a DATE value is required, it should also have a Date Picker Calendar adjacent to it.
    Could you pls shed some light on this issue and help me out.
    Thanks
    ~Siva(ji)

    <HTML>
    <script language="JavaScript" type="text/javascript">
    <!--
    var pUpWidthc = 300; //Change the pUpWidthc to your requirements.
    var scrAvailc = 400;     //Change to your available screen width. You see in
    //this eBooks' middle frame, the frame width is
                                                                //equal to 410 . So whether your using frames or
                                                                //or a full 800 pixel screen, you must calculate
                                                                //your available screen width.
    var PopUpC = document.getElementById("pUpc");
    document.write('<div id="pUpc" style="visibility:hidden;z-index:4;width:'+pUpWidthc+';position:absolute;"></div>');
    function cstmPup(objC,c){
    popUpC = document.getElementById("pUpc");
    popUpC.innerHTML = c.innerHTML
    popUpC.style.left = getPos(objC,"Left");
    var scrNeedc = getPos(objC,"Left") + pUpWidthc;
    if (scrNeedc > scrAvailc){
    //The number 10 below is an extra offset x value applied when the
    //definitional popup box positions beyond your screen width. You
    //can change this number to fine tune your "beyond screenwidth" positioning.
    var scrOffsetC = getPos(objC,"Left") + pUpWidthc - (scrAvailc);
    popUpC.style.left = getPos(objC,"Left") - (scrOffsetC - 0);
    popUpC.style.top = getPos(objC,"Top") + objC.offsetHeight;
    popUpC.style.visibility = 'visible';
    fill();
    function fill()
         var noOfRows=7,noOfCols=7,i=0,j=0,day=1,x;
    var d1=FirstDayOfWeek(7,2008);
    //40     
         for(i=1;i<noOfRows;i++)
              x=document.getElementById('myTable').insertRow(i);
              for(j=0;j<noOfCols;j++)
                   var y=x.insertCell(j);
                   if( ( i==1 && j<d1))
                   y.innerHTML="";
                   else if(day<=DaysInMonth(7,2008)){
                   y.innerHTML=day;
                   day++;
    //document.write(FirstDayOfWeek(7,2008));
    function FirstDayOfWeek(m,y)
    var i;
    var dow = 6;
    //document.write("Hello");
    for (i=1583; i<y; i++)
    dow += (LeapYear(i)) ? 2 : 1;
    for (i=1; i<m; i++)
    dow += DaysInMonth(i,y);
    return dow % 7;
    function DaysInMonth(m,y)
    // m is the month number (1,2,3,...12), y is the year number (four digits)
    switch (m)
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12: return 31;
    case 2: if (LeapYear(y))
    return 29;
    else
    return 28;
    default: return 30;
    function LeapYear(y)
    return (y % 4==0) && ((y % 100!=0) || (y % 400==0));
    function getPos(objC,sPos){
    var iPos = 0;
    while (objC != null) {
    iPos += objC["offset" + sPos];
    objC = objC.offsetParent;}
    return iPos;
    function hPopUpc(){
    popUpC = document.getElementById("pUpc");
    popUpC.style.visibility = 'hidden';
    //-->
    </script>
    <BODY
    <button id="c1" onclick="cstmPup(c1,pUpCstm)">Custom PopUp</button>
    <'div' id="pUpCstm" style="display:none;">
    <'div' id="myid" align="left" style=" width:100%; height:100%; background:#cccccb; border:1px solid black; border-top:1px solid white; border-left:1px solid white; padding:10px; font:normal 10pt tahoma; padding-left:18px "> <b>Rich Message Boxes</b>
    <hr size="1" style="border:1px solid black;">
         <div style="width:220px; font-family:tahoma; font-size:80%; line-height:1.5em"><br>
              <table border ="1" id="myTable">
                   <TR>
                        <TD> SUN </TD>
                        <TD> MON </TD>
                        <TD> TUE </TD>
                        <TD> WED </TD>
                        <TD> THU </TD>
                        <TD> FRI </TD>
                        <TD> SAT </TD>
                   </TR>
              </table>
         <br><br>
         </div>
         <br>
         <div>
    <button tabindex="-1" onclick="hPopUpc()" style="border:1px solid black; border-left:1px solid white; border-top:1px solid white; background:#cccccc ">Close Message</button>
    </div>
    <?BODY
    </HTML>
    Message was edited by:
    mchepuri
    Message was edited by:
    mchepuri
    Message was edited by:
    mchepuri

  • Help posting correct Array[value] to JSP page

    Hello,
    Can someone please tell me what is wrong with this? I am posting the following page (only a portion of the page is listed below) to another jsp page. It consists of a listing of books for sale. Next to each book is a separate "add to cart" button. I want to send the corresponding "isbn" (indexed in an Array) to the next page. When I add print stmts for each record, I can see that the correct isbn is attached to each book.
    The problem is that when I post this to the next page, the formparm for isbn is always the 1st isbn in the array, instead of the selecgtedIsbn. Why???
    Thanks in advance!
    <CODE>
    <% for(int i=0; i < isbnValues.length; i++) {  %> 
    <TABLE>
    <% if ( isbnValues[i] != null) { %>   
    <tr>
    <td> <B><%= titleValues[i] %> </B> </td>     
    <INPUT TYPE="HIDDEN" NAME="selectedIsbn" VALUE="<%= isbnValues[i] %> "></INPUT>
    <INPUT TYPE="HIDDEN" NAME="selectedPrice" VALUE="<%= priceValues[i] %> "></INPUT>
    <td align="right"> <i>Price: </i>
         <%      DecimalFormat df = new DecimalFormat("$#,##0.00");
              String strPrice = df.format(Double.parseDouble(priceValues));
         %>
              <%= strPrice %>     <br>
    </td>
    <td align="right"><i>Quantity:</i>      
         <INPUT TYPE="TEXT" NAME="qty" VALUE="1"></INPUT> <br> </td>
    <td align="right">
         <INPUT TYPE="SUBMIT" VALUE="Add to Shopping Cart"></INPUT> <br>
    </td>
    </tr>
    <% } %>     <%-- end if isbn --%>     
    </TABLE>
    <% } %> <%-- end for loop --%>     
    </CODE>

    Hi,
    I have the indexes, but they were somehow removed when I posted the code. I used the wrong tags.
    I used the right tag and added spaces around the [" i "].
    Let's try again... Here's the code:
    <% for(int i=0; i < isbnValues.length; i++) {  %> 
    <TABLE>    
    <% if ( isbnValues[ i ] != null) { %>   
    <tr>
    <td>  <B><%= titleValues[ i ]  %> </B> </td>     
    <INPUT TYPE="HIDDEN" NAME="selectedIsbn" VALUE="<%= isbnValues[ i ] %> "></INPUT>
    <INPUT TYPE="HIDDEN" NAME="selectedPrice" VALUE="<%= priceValues[ i ] %> "></INPUT>
    <td align="right">  <i>Price: </i>
         <%      DecimalFormat df = new DecimalFormat("$#,##0.00");
              String strPrice = df.format(Double.parseDouble(priceValues[ i ]));
         %>  
              <%= strPrice %>     <br>
    </td>
    <td align="right"><i>Quantity:</i>                 
         <INPUT TYPE="TEXT" NAME="qty" VALUE="1"></INPUT>   <br> </td> 
    <td align="right">
         <INPUT TYPE="SUBMIT" VALUE="Add to Shopping Cart"></INPUT> <br>
    </td>
    </tr>
    <% } %>     <%-- end if isbn  --%>     
    </TABLE>
    <% } %>      <%-- end for loop  --%>     

  • Sending colour from a JSP page into a MySQL database field

    Dear All,
    I am working on trying to send different colours into a MySQL database field from a JSP page.
    This is so that I can represent different pieces of data on my webpage tables in different colours providing status depending on the user request.
    What is the best way to write JSP code for this?
    thanks,
    Alasdair

    Double-posted:
    http://forum.java.sun.com/thread.jspa?threadID=598637

  • JSP Page - HTML fields validator

    We are designing this new project, which involves writing lots of JSP pages. Now the HTML pages will be designed by Web designer. but the actual code for JSP page will be written by developers.
    We have a repository containing field names. This repository can be in XML file/DB etc.
    Our requirement is that the web designer can develop any HTML page but the field names should only be from the given repository. So do we have any development tool(s) which can do the same? or do we have any web page validator? or can somebody suggest what will be the best way to do it, if we have to develop some code

    Hi Rahul,
    You can print your dynamically generated jsp page by using Javascript code
    Try this code in the head region
    <script language="Javascript">
    function print()
    document.print();
    </script>
    in the hyperlink <a href="Javascript:print();>print</a>
    keep me posted on your progress..
    Prakash                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to retrieve data from a jsp page

    I have created a page with some text boxes, file, submit button. In my Ist jsp, i am dynamically add Text boxes and File (for Uploading).
    In the 2nd jsp, i am used Jakarata FileUpload API. I am able to retrieve all data and files except that value of dynamicall added text boxes. That is, I cannot retrieve data from dynamically added text boxes.
    Using Jakarata FileUpload API, i can retrieve values of form data using
    getString() method.
    I want to know that there is any way or method for retrieving form data values into String Array.
    regards
    madhu
    [email protected]

    Use parseRequest(request) to get the file information as you already are doing. However, I dont know how you can use request.getParameter("textField1") to get the other fields from the page. My work-around is as follows:
    Change your submit button to an ordinary button and add an onClick event to it. Then in the javascript function that supports the onClick, add the textField1 as follows:
    <form name="fileUploadForm" method="post" action="someAction" (((more code code here)))))
    function submitButtonClick(){
    document.fileUploadForm.action=
    document.fileUploadForm.action+
    "?textField1="+document.fileUploadForm.textField1.value"+
    "&textField2="+document.fileUploadForm.textField2.value"+
    "&textField3="+document.fileUploadForm.textField3.value";
    document.fileUploadForm.submit();
    As you can see in the above code, I append the textField1 name/value pair to the end of the action. Now in the server, you can use getParameter("textField1");

  • Repeater fails using {container.item} context within included JSP pages

    Greetings,
    I'm using Bea Workshop 8.1.2 and netui's based framework.
    I'm experiencing a problem relating to the use of jsp:insert tags as a way of templating the code as to make it more maintainable and cost effective.
    The problem arises when using repeaters and then binding a <netui> tag with a "container.item" context inside the included jsp page.
    Example:
    On a PageController we define on its scope a rather simple data structure:
    public String[] array={"Item1","Item2","Item3"}
    The associated index is as follows:
    index.jsp
    <netui:html>
    <netui-data:repeater dataSource="{pageFlow.array}">
    <netui-data:repeaterHeader></netui-data:repeaterHeader>
    <netui-data:repeaterItem>
    <netui:label value="{container.item}"/><br>
    </netui-data:repeaterItem>
    <netui-data:repeaterFooter></netui-data:repeaterFooter>
    </netui-data:repeater>
    </netui:html>
    This works as expected, it prints the data in the array list. Fine.
    Now, with the <jsp:insert> tag usage, we get two files index.jsp and body.jsp:
    index.html
    <netui:html>
    <netui-data:repeater dataSource="{pageFlow.array}">
    <netui-data:repeaterHeader></netui-data:repeaterHeader>
    <netui-data:repeaterItem>
    <jsp:include page="body.jsp" flush="true"/>
    </netui-data:repeaterItem>
    <netui-data:repeaterFooter></netui-data:repeaterFooter>
    </netui-data:repeater>
    </netui:html>
    body.jsp
    <netui:html>
    <netui:label value="{container.item}"/>
    <netui:label value="{pageFlow.array[0]}"/>
    </netui:html>
    With this example the {container.item} tag fails with this exception:
    "Caught exception when evaluating expression "{container.item}" with available binding contexts [actionForm, pageFlow, globalApp, request, session, appication, pageContext, bundle, container, url, pageInput]. Root cause: com.bea.wlw.netui.script.xscript.IllegalContextStateException: The Tag "com.bea.wlw.netui.tags.html.Label@cb5dce" does not have a valid parent of type DataAccessProvider. The expression "container["item"]" requires a parent of this type."
    BUT - and here is my problem with this - the label tag with {pageFlow.array[0]} PRINTS THE DESIRED ELEMENT.
    Also, on an extended example with a <form> tag around the main index html and the array structure inside a FormData class, {actionForm.array[0]} ALSO PRINTS THE DESIRED ELEMENT.
    Only {container.item} gloriously fails with an exception complaining about IllegalContextStateException.
    This is a total nonorthogonal behaviour, the features do not work as expected and indeed, with the importance of repeaters for netui's development, this preclude us from the minimum standard for structured web application design.
    Does anyone have any clue about this behaviour? If not a fix, at least an explanation...
    Thanks in advance.

    I am trying to insert multiple rows I when submited I am get ting only 1 row in the DatabaseForm.
    my netui.log file shows this error:
    29 Oct 2004 17:25:48,941 WARN NetUIReadVariableResolver []: Could not create a ContextFactory for type "com.bea.netuix.servlets.script.PortalVariableResolver$PortalContextFactory" because the ContextFactory implementation class could not be found.
    29 Oct 2004 17:26:35,288 ERROR SortFilterColumn []: Unable to load /com/bea/wlw/netui/databinding/grid/filter/filter-window.properties. Using com.bea.wlw.netui.tags.databinding.grid.util.grid
    Throwable: java.util.MissingResourceException: Can't find bundle for base name /com/bea/wlw/netui/databinding/grid/filter/filter-window.properties, locale en_US
    Stack Trace:
    java.util.MissingResourceException: Can't find bundle for base name /com/bea/wlw/netui/databinding/grid/filter/filter-window.properties, locale en_US
    at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:804)
    at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:773)
    at java.util.ResourceBundle.getBundle(ResourceBundle.java:511)
    at com.bea.wlw.netui.tags.databinding.grid.column.SortFilterColumn.<clinit>(SortFilterColumn.java:143)
    at jsp_servlet._activitychange.__grid._jspService(grid.jsp:21)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:463) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    at com.bea.wlw.netui.pageflow.PageFlowJspFilter.doFilter(PageFlowJspFilter.java:208) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:316)
    at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.superForward(PageFlowRequestProcessor.java:1301)
    at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor$DefaultHttpRedirector.forward(PageFlowRequestProcessor.java:1317)
    at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.doForward(PageFlowRequestProcessor.java:1199)
    at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.processForwardConfig(PageFlowRequestProcessor.java:1093)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
    at com.bea.wlw.netui.pageflow.PageFlowRequestProcessor.process(PageFlowRequestProcessor.java:650)
    at com.bea.wlw.netui.pageflow.AutoRegisterActionServlet.process(AutoRegisterActionServlet.java:527)
    at com.bea.wlw.netui.pageflow.PageFlowActionServlet.process(PageFlowActionServlet.java:152)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6456)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    29 Oct 2004 17:27:31,164 WARN FlowController []: Could not find exception handler method exceptionHandler for java.lang.ArrayIndexOutOfBoundsException.
    29 Oct 2004 17:27:31,165 WARN FlowController []: Could not find exception handler method exceptionHandler for java.lang.IndexOutOfBoundsException.
    29 Oct 2004 17:27:31,165 WARN FlowController []: Could not find exception handler method exceptionHandler for java.lang.RuntimeException.
    The actionForm uses a FormData which has a Array of all the fields that need to be populated.
    Any idea why only 1 row shows up ?.
    Thanks
    Raghav

  • No. of javabeans in jsp pages

    Hi,
    If i am having 180-200 textfield in a jsp page and i want to submit the whole data in database table then how many beans should be used to improve the performance . Can it be done using only single bean and if not then what should be the criteria to split it in multiple bean ?

    I am not sure if I understand correctly, but do you have 180-200 different text fields? If so, of course you can do it in one bean. I would suggest either passing in an ArrayList or some sort of similar structure ... maybe just an array ... and have the bean do the work. I can't imagine a problem that would 'require' you to use multiple beans for one operation. Your SQL statement will probably be very long, but regardless, one bean should be able to handle it without a problem.
    dan

Maybe you are looking for