MohanRaj Gurubatham

Greenhorn
+ Follow
since Sep 05, 2001
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 MohanRaj Gurubatham

Hi,
I am sorry for not informing you in the previous reply itself that I have tried with the content type as application/octet-stream also.
Here also I am getting the same problem.Please fix this.
Thank you in advance.
19 years ago
Try this...

[ October 11, 2002: Message edited by: Mike Curwen ]
19 years ago
Hi,
This is my code...
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.net.*;
public class SendFileN extends HttpServlet {
public void init(ServletConfig conf) throws ServletException {
super.init(conf);
}
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
// ##########################################################################
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
String fileURL="http://localhost/webstore/resources/java/app/CConverter111111.jad";
try {
URL url =new URL(fileURL);
URLConnection connection = url.openConnection();
connection.setDoInput( true );
connection.setDoOutput( true );

res.setContentType("text/plain");
res.setHeader("Content-disposition", "attachment; filename=CConverter111111.jad");
ServletOutputStream out = res.getOutputStream();

bis = new BufferedInputStream(connection.getInputStream());
bos = new BufferedOutputStream(out);

byte[] buff = new byte[2048];
int bytesRead;

while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
out.println();
return;

} catch(final MalformedURLException e) {
System.out.println ( "MalformedURLException." );
throw e;
} catch(final IOException e) {
System.out.println ( "IOException." );
throw e;
} finally {
if (bis != null)
bis.close();
if (bos != null)
bos.close();
}
}
}
/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
When I run this servlet sometime I am getting the expected result. But some time it prints the file contents in the browser itself.
Please fix this.
Thank you in advance.
19 years ago
Hi,
A servlet using which I need to return a file which will automatically invoke the Save As.. window or any other downloading application.
Give direct application link to the user is not needed here.
This some what similar to Java site. In this site for downloading any SDKs or any files we will not be given with the direct URL. A servlet will lead to the file after few clicks. I need to setup the same functionality in my program.
Please clear me this doubt with good examples.
Thank you in-advance.
19 years ago
We are also suffering in this matter. Please any one help with sample code to trace the Mobile Phone number or IMEI number programmatically.
This timely help will definetly be appreciated from the bottom of the heart.
Regards,
G.Mohanraj :roll: This timely help will definetly be appreciated from the bottom of the heart.
19 years ago
Hi everybody,
Could any one help me with sample code to start and stop a Thread which will run in a remote server.
Thanking you in advance,
Mohanraj.G
Hi,
I need to close a server which is running in a console through a client program or in the same program by passing arguments.
I have used close() method of ServerSocket class.. but it is not working. I have given the spurce bellow which I have used.

public void run()
{
try
{
ss= new ServerSocket(config.getServerPort());
int localPort = ss.getLocalPort();
logger.datedLog("\n\n"+NAME+" is listening on port "+localPort+".");
int j=0;

while(!stopRequested)
{

Socket client = ss.accept();
runThread=new XMLInterfaceThread(client,config,logger);
runThread.start();
}
stop();

}
catch(IOException ex)
{
logger.datedLog("Unable to listen on "+config.getServerPort()+".");
System.exit(0);
}

}
// --------------------
public void stop()
{
stopRequested=true;
try
{
if(ss!=null)

{
logger.datedLog("Shutingdown XMLInterface ...");
runThread.interrupt();
ss.close();
}
else
{
logger.datedLog("XMLInterface is not connected.");
}

}
catch(IOException ioe)
{
logger.datedLog("Unable to close the XMLInterface ."+ioe.getMessage());
}
}
// ------------------------
how could I call this stop() method from a client program.
If I create a new instance of the server class it comes into the else part of the stop() method.
solution with source would be appreciated.
Thank you in advance,
GMohanraj
I am realy sorry. Still I am not getting. Why don't you send me the entire code which you have used.
Sorry to trouble you.
With regards,
GMohanraj
Yes you are very correct Jamie,
Thank you.
But this works only when there is a record in the table. My intention is to get the actual size of a field of a table in a database without considering, wheter there is a record or not.
I have written here the code which I have used.
Please go thru it and guide me where to change to succeed.
Thanking you in advance
GMohanraj

ResultSet rslt=stmt.executeQuery("SELECT * FROM user");
ResultSetMetaData rsmd=rslt.getMetaData();
int noCol=rsmd.getColumnCount();
String colName="";
int colSize=0;

System.out.println("Column Name | Column Size");

while (rslt.next())
{

for(int i=1; i<=noCol;++i)
{
colName=rsmd.getColumnName(i);
colSize=rsmd.getColumnDisplaySize(i);
System.out.println(colName+" | "+colSize);
}
System.out.println("----------------------------");
}
Thank u Bosun,
already I have tried using ResultSetMetaData, but it gives only the default size. For example it gives the size of the DATE field in MySQL as 10, but it doesn't care about other fields like varchar(20).
I need to know the size which we have set for that field.
Please help me to solve this.
With Regards,
GMohanraj
Hi Friends,
could any one help me with sample code to get field size of a column in a data base table.
Thanking you in advance.
With Regards,
GMohanraj

Thank you Jessica, but I need a solution thru coding itself.
Timely help will really be appriciated.
MohanRaj Gurubatham

Originally posted by Jessica Bradley:
This isn't code that will allow you to maintain session, but a product, its part of the Total-e-Mobile product by HP Bluestone, the tool is called the Universal Session Manager (USM)
Basically, the USM stores the session data for you, seeing as though many devices don't have the ability to store cookies.
Hope that helps.


20 years ago
Hi,
I am posting it second time.
Could any one help me with code, how we could maintain session in microbrowsers ?
As of now I am sending query strings to satisfy some requirements, but this is not safe if I pass any confidential data.
I have not tried URLEncoding method.
Thanks in advance,
With Regards,
MohanRajG
20 years ago
Hi,
I am posting it again.
Could any one help me with code, how we could maintain session in microbrowsers ?
As of now I am sending query strings to satisfy some requirements, but this is not safe if I pass any confidential data.
I have not tried URLEncoding method.
Thanks in advance,
With Regards,
MohanRajG

[This message has been edited by MohanRaj Gurubatham (edited October 19, 2001).]
20 years ago

Originally posted by Bosun Bello:
This worked for me. You may need to tweak it a little bit to suit your needs.

Bosun



Thank you verymuch Bosun. It is working for me also without chaning anything.
I was trying with the following code for MySQL
ResultSet rs1=stmt.executeQuery("show tables");
while(rs1.next())
{
System.out.println("Tables.....:"+rs1.getString(1));
}
But it is vendor specific where as the solutions which you gave is general. I really appriciate you.
With Regards
MohanRajG