Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Can't print actual values “request.getparameterValues” in JSP

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Can't print actual values “request.getparameterValues” in JSP

    When I'm Dispatching a JSP page through Servlet by the following code:

    String[] UserList = ViewAllUserBasedOnRights(UserViewBy);
    request.getRequestDispatcher("/test/TestGetParameterValues.jsp?UserList="+UserList+"") .forward(request, response);

    And the JSP page shows "**[Ljava.lang.String;@8b3f2a**".

    Details:

    //View users based on user roles
    public static String[] ViewAllUserBasedOnRights(String UserName) throws Exception{
    String[] retVal = null;
    Connection con=null;
    try{
    con= DatabaseConnectionManager.getDatabaseConnectionMan ager().getConnection(DatabaseConnectionManager.EAG RO_APP_DB);
    con.setAutoCommit(false);
    Statement stmt = (Statement) con.createStatement();
    Statement stmt1 = (Statement) con.createStatement();
    String SQLStringCount = "SELECT COUNT AS COUNT FROM MASTER_USER_DATA WHERE " +
    " USER_NAME NOT IN(SELECT A.USER_NAME FROM USER_TO_ROLE_MAPPING A, MASTER_ROLE_DATA B WHERE "+
    " A.ROLE_NAME = B.ROLE_NAME AND A.ROLE_IDENTIFIER = B.ROLE_IDENTIFIER AND "+
    " B.ROLE_PRIORITY < (SELECT MIN(B.ROLE_PRIORITY) FROM "+
    " USER_TO_ROLE_MAPPING A, MASTER_ROLE_DATA B WHERE "+
    " A.ROLE_NAME = B.ROLE_NAME AND A.ROLE_IDENTIFIER = B.ROLE_IDENTIFIER AND "+
    " A.USER_NAME = '"+UserName+"'))";
    try(ResultSet rs = stmt.executeQuery(SQLStringCount)){
    int count = -1;
    while(rs.next()){
    count = Integer.parseInt(rs.getString("COUNT"));
    }
    if(count > 0){
    String SQLString = "SELECT USER_NAME FROM MASTER_USER_DATA WHERE "+
    " USER_NAME NOT IN(SELECT A.USER_NAME FROM "+
    " USER_TO_ROLE_MAPPING A, MASTER_ROLE_DATA B WHERE "+
    " A.ROLE_NAME = B.ROLE_NAME AND A.ROLE_IDENTIFIER = B.ROLE_IDENTIFIER AND "+
    " B.ROLE_PRIORITY < (SELECT MIN(B.ROLE_PRIORITY) FROM "+
    " USER_TO_ROLE_MAPPING A, MASTER_ROLE_DATA B WHERE "+
    " A.ROLE_NAME = B.ROLE_NAME AND A.ROLE_IDENTIFIER = B.ROLE_IDENTIFIER AND "+
    " A.USER_NAME = '"+UserName+"') ORDER BY USER_NAME ASC)";

    System.out.println("SQLString: "+SQLString);
    try(ResultSet rs1 = stmt1.executeQuery(SQLString)){
    ArrayList<String> stringList = new ArrayList<String>();
    while(rs1.next()){
    stringList.add(rs1.getString("USER_NAME"));
    }
    String[] temp = new String[stringList.size()];
    retVal = (String[]) stringList.toArray(temp);
    con.commit();
    rs1.close();

    }catch(SQLException e){
    try{
    if(con!=null)
    extracted(con);
    }catch(Exception ex){}
    }
    }
    }catch(SQLException e){
    try{
    if(con!=null)
    extracted(con);
    }catch(Exception ex){}
    }

    }catch(SQLException e){
    try{
    if(con!=null)
    extracted(con);
    }catch(Exception ex){}
    }
    return retVal;
    }


    Code of my JSP page:

    <table style="border:1px solid black;bor

    der-collapse:collapse;" width="100%">
    <tr>
    <th style="border:1px solid black;" align="center" width="15%">Serial no.</th>
    <th style="border:1px solid black;" align="center" width="70%">User Name as email</th>
    </tr>
    <%
    String[] UserList;
    UserList = (String[])request.getParameterValues("UserList");
    for(int i = 0; i < UserList.length; i++){
    %>
    <tr>
    <td style="border:1px solid black;" align="center"><%=i+1%>
    </td>

    <td style="border:1px solid black;" align="left" ><%=UserList[i]%>
    </td>
    </tr>
    <% } %>
    </table>


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Can't print actual values “request.getparameterValues” in JSP

    And the JSP page shows "**[Ljava.lang.String;@8b3f2a
    That is from the toString() method for a String array. If you want to format the contents of the String array for viewing use the Arrays class's toString() method.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: February 8th, 2012, 12:08 AM
  2. Replies: 1
    Last Post: January 13th, 2012, 09:02 AM
  3. In jsp page After decimal i need only 2 values(for ex:477.74)
    By shashib09 in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: August 23rd, 2011, 06:00 AM
  4. Replies: 1
    Last Post: March 22nd, 2010, 04:34 PM
  5. Get <SELECT> tag values on other jsp page
    By nehakuls in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: November 18th, 2009, 02:29 AM

Tags for this Thread