Solved

Y the jsp put out the hex codes?

Posted on 2001-08-02
10
171 Views
Last Modified: 2010-03-31
Hi,

It should be some english words that retrieved from the oracle database.But now I got some hex codes.

I have defined the same character set on both server and client side.

I don't know what's wrong!

Thanks in Advance.

Vivian Qi

0
Comment
Question by:vivianQQ
  • 5
  • 5
10 Comments
 
LVL 3

Expert Comment

by:Sendoh
ID: 6344043
hi !! guess u've got to post some code in order for us to help u

:)
0
 

Author Comment

by:vivianQQ
ID: 6344060
0x3938E5BAA6E4B990E9989F 0x3938646567726565
 0x42656361757365206F6620796F75 0xE69CAAE79FA5
 0x3938E5BAA6E4B990E9989F 0x3938646567726565
 0x42656361757365206F6620796F75 0xE69CAAE79FA5
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 6344096
hahaha no the hex codes but the applet code...:)
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:vivianQQ
ID: 6344109
what is applet code?

I took for granted that it's the hex codes because they R all begin with 0x.

Anyway how to solve the problem?

ThanX
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 6344114
i mean how u retrieve this codes from oracles....
using asp ??
or jsp ??
or applets ??
0
 

Author Comment

by:vivianQQ
ID: 6344156
lol,what a stupid mistake!

I use jsp+JavaBeans
the code that associated with them is listed below:
test.jsp

<%@ page language="java" import="ssei.*"%>
<%@ page contentType="text/html; charset=GBK"%>

<HTML>
<HEAD>
<jsp:useBean id="Searcher" scope="request" class="ssei.sseiBean" >
    <jsp:setProperty name="Searcher" property="key_Word" param="key_Word"/>
    <jsp:setProperty name="Searcher" property="key" param="key"/>
</jsp:useBean>
<title>test</title>
<body>
    <%
     String test1="select CN_NAME from singers where singer_ID='2'";
     String test[]=songSearcher.doSelect(test1);
    %>
    <p><%=test[0]%>
</body>
</html>

the method that in the javabean is:
    public String[] doSelect(String selectString) throws SQLException{

        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

        // Connect to the database
                Connection conn =
            DriverManager.getConnection (dbDriver,dbUser, dbPwd);

        // Create a Statement
        Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);

        ResultSet rset = stmt.executeQuery (selectString);
        int i=0;
        while (rset.next ())
            i++;
        String[] temp=new String[i];
        rset.beforeFirst();
        for(int j=0;j<i;j++){
            rset.next();
            temp[j]=rset.getString(1);

        }
        rset.close();
        stmt.close();
        conn.close();
        return temp;
    }




0
 
LVL 3

Accepted Solution

by:
Sendoh earned 50 total points
ID: 6344176
hi !!
think it is quite risky to return a string array from a functions...
actually u can try following code for ur bean :

public String doSelect(String selectString) throws SQLException{

       DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

       // Connect to the database
               Connection conn =
           DriverManager.getConnection (dbDriver,dbUser, dbPwd);

       // Create a Statement
       Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);

       ResultSet rset = stmt.executeQuery (selectString);
       int i=0;
       String retVal="";
       
       while (rset.next ())
       {
           if(i==0)
                   retVal = rset.getString(1);
              else
                   retVal += ";"+  rset.getString(1);
           i++;
        }
       rset.close();
       stmt.close();
       conn.close();
       return retVal;
   }


then following for ur jsp :

<%@ page language="java" import="ssei.*"%>
<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.util.*" %>

<HTML>
<HEAD>
<jsp:useBean id="Searcher" scope="request" class="ssei.sseiBean" >
   <jsp:setProperty name="Searcher" property="key_Word" param="key_Word"/>
   <jsp:setProperty name="Searcher" property="key" param="key"/>
</jsp:useBean>
<title>test</title>
<body>
   <%
    String test1="select CN_NAME from singers where singer_ID='2'";
    String test=songSearcher.doSelect(test1);
    StringTokenizer st = new StringTokenizer(test,";");
   
    while(st.hasMoreTokens())
    {
        %>
        <p><%=st.nextToken()%> <br>
       <%
     }
       %>
</body>
</html>

Hope it helps... :)

0
 

Author Comment

by:vivianQQ
ID: 6357985
Thank U.
It is caused by the string array!
but Y returning the string array can cause the problem?
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 6358002
not sure what exactly was the problem...
but usually return an array from a function will cause problem....
think is due to the mem allocation problem cuz the array is actually localise...:P

regards Sendoh
0
 

Author Comment

by:vivianQQ
ID: 6358417
Thank U very much!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
simple java question 3 59
varialbe initialization 11 37
How do I remove an object from a 3 40
passing enum to a method 4 23
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question