Daniel Washington

Ranch Hand
+ Follow
since Oct 26, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Washington

sorry about my explanation.
"it doesn't work" means after I changed <session-timeout> value to -1,
and the weblogic server restart too.And I repeat the above operations:
first login in the web site,the session is not null surely,then change the
system time ,the jsp pages exception happen.
what i thought is maybe one of the two reason can explain these scene:
1) the value of -1 for <session-timeout> cannot solve the problem in my case.
2) when i login in web site in 2005-11-16,the session is taged the timestamp or unique id somewhat by weblogic server, and i change time to 2006-1-16,although the session.isvalid() return true,but the session id changed??? (it seems the reason is eisegesised)
14 years ago
JSP
I deploy a domain in my pc,and run well.
at the meaning time ,I change the PC TIME from 2005-11-16 to 2006-1-16,
then ,all the jsp pages using SESSION Object was wrong ,because the session is null.

so I guess maybe the server compare the new time to the beginning time,thought the session has last for 2 monthes, so the session is invalid .
but i changed the tag <session-timeout> in the config.xml of weblogic server,restart the server,it doesn't work.


Does anybody know these problem?
thx and bow!
14 years ago
JSP
very thx to Jules,I have already figured out this problem with your help.
now I post my complete JSP code ,hope can help others.
<%@ page contentType="text/html; charset=ISO-8859-1" %>
<%@ page import="java.sql.*,java.io.*"%>

<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc dbc:testforwebsphere","sa","sa");
String sql = "select * from testforphoto where test='111'";
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rs =pstmt.executeQuery();
rs.next();
InputStream in = rs.getBinaryStream("photo");
OutputStream sos = response.getOutputStream();

int len = 0;
byte[] b = new byte[1024];
response.reset();
response.setContentType("image/gif");
while((len = in.read(b)) > 0)
sos.write(b);
in.close();
sos.close();
%>
<html>
<body>
show the picture successfully!
</body>
</html>

Originally posted by Julian Kennedy:
So, is your question how to read a Blob type from a database? If you look at the thread I linked to, that may help you. If you give it a bit of thought you can easily adapt my example to work for you.

15 years ago
JSP
sorry,it seems your code doesn't work,your codes fetch byte array from a real my-image.jpg and show it using servlet,but I mean how to show the picture which is stored in Blob type.
thx anyway

Originally posted by Julian Kennedy:
Hi Daniel,

Here is a simple example that I recently posted in this thread.



Do it in a Servlet, not in a JSP.

Hope that helps.

Jules

15 years ago
JSP
thx to peter and Jules anyway.
But I am puzzled that if the results is stream.we know
"rs.getString(1)
rs.getString(2)
"which sentence of them is first is doesn't matter,so we can sure
the content is just fixed by the index or columnname,then why we cannot
find that content by columnname once a time?
just cannot understand.

Originally posted by Peter den Haan:
This was put in there to allow the driver to stream the results at the field level. So when you call rs.getString(2), the driver might just read the second field of the current record from the server's data stream and return that to you - with no way to go back to the first field, or even to return the field a second time.

- Peter



ResultSet rs=statement.executeQuery("select a,b from table1");
String str1=rs.getString("a"); //this is surely correct

String str2=rs.getString("a");

but when do rs.getString("a") again,it is wrong and some strange error happen ,why?the "rs" still wait on the current cursor,why can't i do the
same rs.getString("a") two times?

anybody have the same experience please give me help,thx a lot!!
In my work,I store pictures as Image type in SQL server.
Now i wanna fetch the pic and show it in JSP,somebody told me that I should
make the pic to a byte array first,so what is next ?
How can I do to make the byte array show as a gif in Jsp?

thx a lot !!!
15 years ago
JSP
Great thanks to Max Rahder and Ernest Friedman-Hill.
what you say really open my mind.
cool.
"At runtime, when you get your connection, that's where your vendor-specific driver provides that vendor's version of Connection. When you ask the connection to create a statement, you get the vendor's version of Statement. Etc."

Originally posted by Max Rahder:
Just to continue Ernest Friedman-Hill's observations...

The people at Sun who created the JDBC interface had it easy. They simply described behavior. It's the people at Oracle or DB2 who had to implement the classes! At runtime, when you get your connection, that's where your vendor-specific driver provides that vendor's version of Connection. When you ask the connection to create a statement, you get the vendor's version of Statement. Etc. As always with polymorphism, your code doesn't really care what kinds of objects it has; your code only cares what those objects can do! Since the vendor's objects implement the interfaces, they are type-compatible with your variables, even though their actual class type is some vendor class you've never heard of. For kicks you might get your Connection, Statement, and ResultSet objects and run something like:
System.out.println(aConnection.getClass.getName());
Again... you don't really care *what* the objects are, but this might help solidify the concept that even though your code only contains references to the interface types, at runtime you actually have the vendor's version.

15 years ago
ybe this is a simple question,but it confused me for a few days.Anyone could help me?
when I read the source code of JDK,such as Java.sql.statement,all the functions in this interface is empty,there are no content, so when some function of them is called ,how can the action happen?
such as:I call java.sql.statement.execute(sql),then what is the "actual source code" of execute()?or there are some code actually behind the execute(),where is it ?

thx a lot. don't shame me
15 years ago
how to do "the seperate pages system" in JSP?
I saw a simple example is like this:add a column named UUID in the table,then everytime user click a page,then
use "select * for table where UUID>=(page-1)*10 and UUID<page*10" to get the resultset.
but I just remember setFetchsize() is doing the same thing,so can i realize the function using it,if true ,how can i do it ,
any suggestion is welcome ,thx a lot
15 years ago
JSP
I am reading the j2me book written by sam.
in my mind,i thought:
CLDC is for specfic device,has some fundanmental API library,such as:java.lang;java.util;
MIDP is profile for some cldc,seems like some addtional api library besides the CLDC,such as javax.microediton.lcdui;javax.microedition.rms;

in one word both cldc and midp are define API,is just the API content is different,am i right???

thx for anyone can solve my confuse!
15 years ago
can I take 286 without scjp?if yes,does it mean I can't get a certification until I pass 286+scjp?and if I pass scjp but before the the certification of scjp is sent to me ,can i take the 286?
thx
RandomAccessFile rowDataFile=new RandomAccessFile("cards.txt","rw");
byte byte1[]=new byte[(int)rowDataFile.length()];
rowDataFile.readFully(byte1,0,(int)rowDataFile.length());
System.out.println(byte1);
....
always print: [B@1fc2fb
but the "Cards.txt" is indeed have some content!
please help me!!!thx
15 years ago
but score is not satisfied,so i am not going to post the score
2 question is from ICE sample test,and 7 question is same with the topic
Sri celamko posted early,but nobody have the true answer,so I am not sure about the answer too.
question about "debug" is in detail,I got the lowest score here.
and you must known every "default" value in the check box,radio button during you create your application.
anyway ,all the question can be found in "WSAD programming guide"SG246957 ,it's just the matter of your memory or you experience.
thanks to everybody given my advice,and I am going to prepare 286.During the preparation for the test,I really can learn a lot from it.
to Peter:
you are so kind,i understand now,especially"a normal WAS installation without all the WSAD-stuff clinging to it".Bow!!!

Originally posted by Peter Kristensson:
Hi.
You would use the WSAD to write your J2EE applications.
Then when you're done, you would deploy the application and run it on a "normal" WAS installation. (You cant actully write applications using the WAS, it's only for running them)
WSAD - write applications.
WAS - run applications.
What might confuse you here is that the WSAD is shipped with a couple of "test servers", which is basically a WAS server that runs inside the WSAD (or at least in close proximity to it). These servers are used for testing your applications. But when it comes to setting whole shebang in production, you'd normally want a normal WAS installation without all the WSAD-stuff clinging to it.
hope this helps
/Peter

15 years ago