Solved

Y the jsp put out the hex codes?

Posted on 2001-08-02
10
167 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
 

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
endX challenge 2 50
Exception after setting jdbc session management 2 38
topping1 challenge 7 53
wordcount challenge 11 78
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…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now