Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!

Mufaddal Khumri

Greenhorn
+ Follow
since Jun 13, 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 Mufaddal Khumri

Hi,
I have a Servlet that creates a PDF and sends it to the client browser. The client browser receives the pdf and displays it if it has the pdf plugin, if not it asks the user to save the file to disk.
The problem occurs on IE and Netscape on Windows XP. When the client browser has the plugin installed, it displays the pdf fine. But lets say the data for the pdf changes and the user sends a new request to the servlet for an updated pdf, the client browser fetches the previously cached pdf ??? How do i stop this from happening ? How do I force the browser to get the "new" pdf and not fetch the old pdf from the cache ? In IE i erased all cached files and i still got the old pdf. It seemed as if the plugin stored the cached pdf ??? (This conjecture might be wrong). In anycase how do i make sure that the client browser gets the new pdf and does not fetch the cached copy?
16 years ago
A few corrections to the code i pasted earlier:
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root");

PreparedStatement pstmt1 = con.prepareStatement("INSERT INTO CLOBTEST " +
"(ID) VALUES (?)");
pstmt1.setInt(1, 2);

pstmt1.executeUpdate();
pstmt1.close();

Statement stmt = con.createStatement();

ResultSet rs1 = stmt.executeQuery("SELECT DESCRIPTION from CLOBTEST");
Vector v = new Vector();
while(rs1.next())
v.addElement(rs1.getClob("DESCRIPTION"));
rs1.close();
stmt.close();
PreparedStatement pstmt = con.prepareStatement("UPDATE CLOBTEST " +
"SET DESCRIPTION = ? WHERE ID = 2");
if(v != null && v.isEmpty() == false)
{
System.out.println("Inside if statement.");

Clob c = (Clob)v.elementAt(0);
c.setString(1, " Hello World ");

pstmt.setClob(1, c);
pstmt.executeUpdate();
pstmt.close();
}
pstmt.close();

con.close();
Hi,
After reading a lot of posts in this forum and else where I am doing the following:
I want to store a huge java String as a CLOB in the MYSQL Database.
I have a table defined like this:
CREATE TABLE CLOBTEST (ID INTEGER NOT NULL AUTO_INCREMENT, DESCRIPTION TEXT, PRIMARY KEY (ID)) TYPE = innoDB;
Next I do this:
PreparedStatement pstmt1 = con.prepareStatement("INSERT INTO CLOBTEST " +"(ID, DESCRIPTION) VALUES (?, empty_clob())");
pstmt1.setInt(1, 2);
pstmt1.executeUpdate();
pstmt1.close();
After this I do this to get the clob objects:

Statement stmt = con.createStatement();

ResultSet rs1 = stmt.executeQuery("SELECT DESCRIPTION from CLOBTEST");
Vector v = new Vector();
while(rs1.next())
v.addElement(rs1.getClob("DESCRIPTION"));
rs1.close();
stmt.close();
Once i have got the clob object, i want to write some data in the clob object from a java string and store the clob to the database
PreparedStatement pstmt = con.prepareStatement("INSERT INTO CLOBTEST " +
"(DESCRIPTION) VALUES (?)");
if(v != null && v.isEmpty() == false)
{
System.out.println("Inside if statement.");

Clob c = (Clob)v.elementAt(0);
c.setString(0, " Hello World ");
pstmt.setClob(2, c);
pstmt.executeUpdate();
}
pstmt.close();
When I run the above code I get the following exception:
java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '())' at line 1"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1697)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1083)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1142)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1876)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1590)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1653)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1492)
at ClobTest.main(ClobTest.java:21)
I am guessing "empty_clob()" might be wrong since i think it is specific for oracle ??? If so , what do i do to get a clob object from mysql ? I need to store a java String inside a Clob object.
Any help on this is greatly appreciated.
Hi,
I have a servlet that generates a PDF document and then sends it to the clients browser. If the client has a PDF plugin for his or her browser, the PDF document opens in the client's browser window, else the client gets a dialog box asking him to save the PDF document to his or her hard disk.
In my web application the client clicks a link which invokes a smaller child window for the PDF to be displayed in. The problem I am facing is that while the PDF is being generated, I need to show the client some kind of notification in this child browser window - Some message like -"Please wait while the document downloads" or something to that tune, could be a gif image of some sort. How do I do this ?
I tried one approach that is i write the header information in my servlet and flush that, so that the client gets that information and starts displaying the PDF as its being genrated, but that did not work. The PDF gets generated sent and then only does it appear in the child window.
Any help on this will be appreciated.
Thanks.
[ September 21, 2003: Message edited by: Mufaddal Khumri ]
16 years ago
Hi,
I have a servlet that generates a PDF document and then sends it to the clients browser. If the client has a PDF plugin for his or her browser, the PDF document opens in the client's browser window, else the client gets a dialog box asking him to save the PDF document to his or her hard disk.
In my web application the client clicks a link which invokes a smaller child window for the PDF to be displayed in. The problem I am facing is that while the PDF is being generated, I need to show the client some kind of notification in this child browser window. How do I do this ?
I tried one approach that is i write the header information in my servlet and flush that, so that the client gets that information and starts displaying the PDF as its being genrated, but that did not work. The PDF gets generated sent and then only does it appear in the child window.
Any help on this will be appreciated.
Thanks.
Before writing code to do this, I was wanting to know if the container provided any mechanism to do this. For invalidating sessions it seems Tomcat's server.xml can be tweaked to include:
<Manager className="org.apache.catalina.session.PersistentManager"
debug="0"
saveOnRestart="false"
maxActiveSessions="-1"
minIdleSwap="-1"
maxIdleSwap="-1"
maxIdleBackup="-1">
<Store
className="org.apache.catalina.session.FileStore"/>
</Manager>
The problem is that even after doing the above, it does not work for me. I did the following test to test my webapp after i put the above in the server.xml:
1. started tomcat.
2. started a browser, logged into MyApp and used it.
3. stopped tomcat and restarted tomcat . (kept the browser window that i was using in step 2 open).
4. went back to my browser window from step 2 and tried to continue using my MyApp by clicking on one of the links to a jsp page. The browser showed me a blank window -
AT THIS POINT I checked the session attribute and it was still existing. My code that redirects the user to the login page checks to see if this attribute is not there or is false. Since its present and is true it does not redirect the user. The only way i can redirect the user to the login page is by invalidating the session he or she is using . For this i made the change to the server.xml.
Any ideas why this isnt working ?
16 years ago
I have got a ServletContextListener that does initialization and cleanup for my webapp. I was wondering if there was a way to:
1. Get the pool of sessions for my webapp (as a collection on which i can iterate or enumerate). this would allow me to call session.invalidate on all these session objects.
2. Invalidate all sessions to my webapp in this Listener ? If not, in what way can I invalidate all sessions when i start / reload my webapp ?
Thanks
16 years ago
Thanks Sashi , but I had come across that link already. I want something more like what Greg described. The button needs to look like a button like JButton , just another shape. Not just a colored circle or something.
17 years ago
Hi.
I am trying to change the shape of JButton. I have understood that for this I have to use the ButtonUI class and the UIManager class. But somehow I havent been able to bridge all the bits of information. Does someone have a code example showing a JButton of a shape other than the standard rectangular shape ?
Regards.
17 years ago