Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Srinivasa Dhamodharan

Greenhorn
+ Follow
since Oct 17, 2000
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 Srinivasa Dhamodharan

Hi! All,
Can anybody suggest me a good book on encryption techniques
in credit card transaction processing etc.
Thanks in Advance
Srinivas
21 years ago
Hi! all,
I need to install oracle in my linux and need to create some mount points now, Can anybody tell me how to create a mount point
?.

Thanks in Advance
Srinivas
21 years ago
Testing Smilies

21 years ago
But I need it to be an unconditional redirection, In the right side html I get all the details and when the user clicks the submit button , it calls a jsp script to go and update in the database and after completing this operation , I need to display a message saying "Registered ... Please Wait " and then redirect to the new html file without any frames.
Hi! all,
I have a web page with two frames and on the right side frame , I am having a registeration details html displayed , after completing the registration I am using the meta refresh to go to a new html page, But the new html page is also showing up in the right side frame , But I want that new page to be displayed without a frame , I am aware if I use a href link to that html
page with a target ="_top" attribute , then I can achieve this,But I need it in automatic redirection.Can anybody help me ?.
Thanks in Advance
Srinivas
Hi! all,
In some of the discussion threads here, I found a String which is
created in the following way
String testString = "Hello"
will not be garbage collected or eligible for garbage collection because it will not be created in the heap but in the string pool.Is this true?.Can anybody give any website reference to confirm this?.
Thanks in Advance.
Hi! Punitha,
I would say that they are correct in the answer , the question states that when it is eligible to be garbage collected,
So as soon as it is assigned a null value the object originally referred by e becomes eligible for Garbage Collection.
But the question should be more specific it should not say e but
the object referred by e.
Hope this clears you.
Srinivas
Hi! all,
In one of my Servlets if I have the JDBC connection in the doget method it connects and the connection stays till the program completion, But if I have it in the servlets init block,
and do some database operation in the doget method , the connection is lost and the connection pointer is pointing to null,
Can anybody tell me why is this happening.
Thanks in Advance
21 years ago
Ashwin,
I am calling this html from a browser using ctrl+0 and then selecting the directory and file name.

Thanks
21 years ago
Brett,
This is my code
// This is my HTML which invokes the applet DbApplet.java
// All the 3 files I mean //dbApplet.html,DbApplet.class,DbServlet.class are stored
// in the same directory

<HTML>
<HEAD>
<TITLE>Database Query Interface</TITLE>
</HEAD>
<BODY>
<CENTER>
<H1>Database Query Interface</H1>
<HR>
<BR>
<!--"CONVERTED_APPLET"-->
<!-- CONVERTER VERSION 1.0 -->
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = "600" HEIGHT = "300" NAME = "DbApplet" codebase="/">
<PARAM NAME = CODE VALUE = "DbApplet.class" >
<PARAM NAME = NAME VALUE = "DbApplet" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.1">
<COMMENT>
<EMBED type="application/x-java-applet;version=1.1" java_CODE = "DbApplet.class" NAME = "DbApplet" WIDTH = "600" HEIGHT = "300" pluginspage="http://java.sun.com/products/plugin/1.1.1/plugin-install.html">
<NOEMBED></COMMENT>
</NOEMBED></EMBED>
</OBJECT>
<!--
<APPLET CODE = "DbApplet.class" WIDTH = "600" HEIGHT = "300" NAME = "DbApplet" >
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
</CENTER>
</BODY>
</HTML>
This is my Applet which calls the DbServlet.class in turn which accesses the database

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class DbApplet extends Applet implements ActionListener {
TextField tfQuery;
TextArea taResults;
Button btnExecute;
public void init() {
Panel p1 = new Panel();
p1.setLayout(new FlowLayout(FlowLayout.LEFT));
p1.add(new Label("Query String:"));
tfQuery = new TextField("", 50);
p1.add(tfQuery);
btnExecute = new Button("Execute Query");
btnExecute.addActionListener(this);
p1.add(btnExecute);
add("North", p1);
taResults = new TextArea(10, 80);
add("Center", taResults);
}
public void executeQuery() {
/* This is part of the code I added in my trial and error but please dont count this
String webServerStr, protocol;
String hostName="localhost";
int port = 8080;

URL hostURL = getCodeBase();
protocol=hostURL.getProtocol();
hostName = hostURL.getHost();
port = hostURL.getPort();
if (port == -1)
{
port = 80;
}
End of trial and error code*/
String qryString = tfQuery.getText();
try {
webServerStr = "http://localhost/servlets/DbServlet";

URL url = new URL(webServerStr);
String qry = URLEncoder.encode("qry") + "=" +
URLEncoder.encode(qryString);
URLConnection uc = url.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setUseCaches(false);
uc.setRequestProperty("Content-type",
"application/x-www-form-urlencoded");

DataOutputStream dos = new DataOutputStream(uc.getOutputStream());
dos.writeBytes(qry);
dos.flush();
dos.close();
InputStreamReader in = new InputStreamReader(uc.getInputStream());

int chr = in.read();
while (chr != -1) {
taResults.append(String.valueOf((char) chr));
chr = in.read();
}
in.close();
} catch(MalformedURLException e) {
taResults.setText(e.toString());
} catch(IOException e) {
taResults.setText(e.toString());

}
catch(Exception e) {
taResults.setText(e.toString());

}
}
public void actionPerformed(ActionEvent ae) {
executeQuery();
}
}
//This is my Servlet Program
//Import Servlet Libraries
import javax.servlet.*;
import javax.servlet.http.*;
//Import Java Libraries
import java.util.*;
import java.sql.*;
import java.io.*;
public class DbServlet extends HttpServlet {
Connection dbCon;
public void init() throws ServletException {
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

dbCon = DriverManager.getConnection("jdbc racle:thin:@localhost:1521 rcl","javauser","javauser");

} catch (Exception e) {
System.out.println("Database connect failed (init)");
System.out.println(e.toString());
return;
}
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
PrintWriter out = res.getWriter();
res.setContentType("text/html");
String qry = req.getParameter("qry");
try {
Statement s = dbCon.createStatement();
ResultSet rs = s.executeQuery(qry);
while (rs.next()) {
out.println(rs.getString(1) + " - " + rs.getString(2));
out.println(rs.getString(3));
out.println ("");
}
} catch (SQLException e) {
System.out.println(e.toString());
return;
}
out.println();
out.close();
}
public void destroy() {
/* Close database connection */
try {
dbCon.close();
} catch (Exception e) {
System.out.println("Error closing database (destroy)");
System.out.println(e.toString());
}
}
}
21 years ago
Frank,
You are correct the browser and the server are in the same machine, I havent tried this particular servlet loading manually from the browser because this connects to database, executes
the query sent by the applet and returns the result set to the
applet, I dont know whether I will be able to run this manually
from the browser, But as I told you earlier I have tried loading manually other servlets which is stored in the same directory as this, and it works.
Thanks.
21 years ago
Thanks for the reply Frank, But I need to throw some more details
in this , I tried the URL which I use to load other servlets for the web browser, In detail I am using Apache Web Server/Jserver with oracle.
So I am storing all my servlets in
c:\programfiles\apachegroup\jserv\servlets
If I need to load any servlet from the browser, for example ,
the IsItWorking servlet from Jserv package , I give the URL
//localhost/servlets/IsItWorking
But if I give the same URL in the URL for opening the servlet from the applet, It gives me file not found DbServlet (My servlet name), I am I doing the right thing here?. Please clarify...
Thanks
21 years ago
Hi! All,
I am trying to load a servlet and run it from an applet,
the servlet has got a connection to an oracle database. Whenever
I click the submit button in the applet which invokes the servlet , I am getting an exception which is as follows
java.net.exception connection refused with no further information
I dont what is this problem?.Can anyone help me solve this?.
Thanks in Advance.
21 years ago
Thanks! Raj,
Seems to be very interesting and challenging , Let me
try it and let you know.
Once again thanks.
Srinivas
21 years ago