honey singh

Ranch Hand
+ Follow
since Apr 26, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by honey singh

Hi I'm using apache-tomcat 4.0.4 to run JSP pages...when I run it on Windows XP where there is no server, I run it on port 8080 and it works nicely...but when I run it on Windows2000 then coz there is IIS istalled there I made the port of Apache-tomcat to 8090...so now the problem is that when I save JSP files in install_di\webapps\root then these pages run...but when I place a servlet file in install_dir\webapps\root\web-inf\classes dir then the sevlet doesn't run...saying it cannot find the file requested...so plz tell me where I'm erring...whether it is port issue or something else?
thanx....
22 years ago
JSP
Is the problem which I had written above related to browser..I'm using IE version 6.0
Do I need to make some changes in the mime types of the browser to display files..
thanx in advance!
22 years ago
JSP
thanx very much for the reply, actually the thing is that the method which u told will work fine with some other characters...but for my case I can't even write like this
String a="C:\jdk\hello.java"
String b=replace(a,"\","\\");
as this will give me compiler error...
actually my function is extracting value from the form when it is submitted having the file field
so data is as follows
-----------------------------7d01ecf406a6
Content-Disposition: form-data; name="FileItem";
****filename="C:\Inetpub\wwwroot\Upload\file1.txt"***********
Content-Type: text/plain
This file has some text in it.
It also has more than one line.
-----------------------------7d01ecf406a6
Content-Disposition: form-data; name="fileaaa";
filename="C:\Inetpub\wwwroot\Upload\pic.gif"
Content-Type: image/gif

so this function is extracting value from here.. and there it is just simply without '\\'
so it will return me in '\' format...
but I need to convert into '\\' format...
please help me!
22 years ago
I'm retrieving the file name from a function and that function returns me the string and now I can't change this.
String fileName="C:\jdk1.2\hello.java"
Now next with this file Name I'm making a file object
File f=new File(fileName);
FileInputStream in=new FileInputStream(f);
but this gives me error..that it doesn't found the specified the file given...
so this means I must give the separator as C:\\jdk1.2\hello.java
but I can't change the value returned to me by the function...
So this means that I have to make a function replace which converts '\' to '\\'
String newfileName=replace(fileName);
so please can anybody tell me how to write this funcion? Actually I can't use replace fn. of String class, as it says that '\' is invalid escape character...u try it and compile the result and tell me
thanx in advance for the favourable response
22 years ago
Hi the gurus here. I'm caught in very helpless position and I think that only gr8 persons like u can solve this problem..here it goes
I'm making an application using jsp and apache-tomcat as the server. Now I want to download the file from the database server. For this I'm using the following code..

cmd="select con_type,f_name from transaction where id='1';
rs=stmt.executeQuery(cmd);
if(rs.next())
{
String contentType=rs.getString("con_type");//con_type is the contenttyp
String fileName=rs.getString("f_name");
}
cmd="select * from transaction where id='1';
rs=stmt.executeQuery(cmd);
beanId.downloadField((rs,"f_file",contentType,fileName);
and the function which is in a bean class is as follows:--
public void downloadField(ResultSet rs, String columnName, String contentType, String destFileName)
throws SQLException, IOException, ServletException
{
if(rs == null)
throw new IllegalArgumentException("The RecordSet cannot be null (1045).");
if(columnName == null)
throw new IllegalArgumentException("The columnName cannot be null (1050).");
if(columnName.length() == 0)
throw new IllegalArgumentException("The columnName cannot be empty (1055).");
byte b[] = rs.getBytes(columnName);
if(contentType == null)
m_response.setContentType("application/x-msdownload");
else
if(contentType.length() == 0)
m_response.setContentType("application/x-msdownload");
else
m_response.setContentType(contentType);
m_response.setContentLength(b.length);
if(destFileName == null)
m_response.setHeader("Content-Disposition", "attachment;");
else
if(destFileName.length() == 0)
m_response.setHeader("Content-Disposition", "attachment;");
else
m_response.setHeader("Content-Disposition", "attachment; filename=".concat(String.valueOf(destFileName)));
m_response.getOutputStream().write(b, 0, b.length);
}
so now when I download the file then it gives me pop-up box with the default name as "Download.jsp" whereas I haven't specified any name. and if I click to open the file...then it opens word document and with alert box saying "C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files\Content\45MFWD2F\Download[1].jsp
Cannot find this file.
Please verify that correct path and file Name are given."
and if I open .html file then it says that nullpointer exception
if I open .class file then it says "IllegalStateException getOutputStream() has already been called for this response!"
any help will be greatly appreciated.
thanx
22 years ago
JSP
Hi Frank,
thanx for the reply...but I had done this also..and then also it gives me the same error..
thanx in advance!
22 years ago
JSP
I had changed the name, now please can I expect my answer to the question..
thanx in advance
22 years ago
JSP
If anybody can help me with the above given problem...Can u tell me to set the content type of the file to the original content type of file...or to set the content type to default application/x-msdownload...?
thanx...
22 years ago
JSP
I'm writing the code for the application. My data is in database and I want to retrieve it...
now the file name is in anchor tag and it hits the JSP page when user clicks on this tag...
so the JSP page uses this code
cmd="select f_file from transaction where id='1'";
rs=stmt.executeQuery(cmd);//f_file is the Blob field
if(rs.next())
String fileName=rs.getString("f_name");
download(rs,"f_file","application/a-msdownload",fileName);
and the function is as follows:-
public void download(ResultSet rs,String columnName,String contentType,String destFileName)
{
byte b[]=rs.getBytes(columnName);
if(contentType==null)
response.setContentType("appliation/x-msdownload");
else
response.setContentType(contentType);
response.setContentLength(b.length);
if(destFileName==null)
response.setHeader("Content-Disposition","attachment;");
else
response.setHeader("Content-Disposition","attachment;fileName=".concat(String.valueOf("destFileName)));
response.getOutputStream().write(b,0,b.length);
}
*********************************
Now the problem is that earlier it was executing with giving opening the file with garbage data in first few words of firs line....
Now today when I tried it didn't worked at all..and instead for .doc or .txt files...it says that file doesn't exist and if I want to create new file...so there is no content at all.
when I open html page it gives the excpetion that the getOutputStream() method is already defined...
so please tell me what to do? I mean what is the problem and what content type to set for different files?
any kind of help will be greatly appreciated, as I'm close to finish this project, but this is the only hassle...
thanx a lot...
22 years ago
JSP
I'm writing more of my code to make myself clear
the structure of the table is
TRANS_NO NOT NULL VARCHAR2(4)
STUD_ID VARCHAR2(6)
F_PATH VARCHAR2(100)
F_NAME VARCHAR2(50)
F_FILE BLOB
F_SIZE VARCHAR2(10)
TRANS_DATE DATE
A_TYPE VARCHAR2(1)
F_ACCESS VARCHAR2(4000)
F_DUPLICATE NUMBER(3)
and the code is:--
cmd="select trans_no,stud_id,f_name,f_size,trans_date,f_access from transaction where a_type='S'";
rs=stmt.executeQuery(cmd);
rs.next();
String a=rs.getString("f_access");
System.out.println(a);///I checked the value here of a is "333"
if(a.equals("333"))
{
System.out.println(rs.getString("trans_no"));
System.out.println(rs.getString("stud_id"));
System.out.println(rs.getString("f_name"));
System.out.println(rs.getString("f_size"));
System.out.println(rs.getString("trans_date"));
System.out.println(rs.getString("f_access"));
}
and the excpetion is as given above....
now if I take out the step
********String a=rs.getString("f_access");*******
then it gives me the result...
thanx for the reply...
I'm using the result set to extract data from the database..
now when I execute the query and take the result from one of the column of the table
String a=rs.getString("f_access");
and now without altering the resultset I again access the rest of the columns
System.out.println(rs.getString("trans_no"));
System.out.println(rs.getString("stud_id"));
System.out.println(rs.getString("f_name"));
System.out.println(rs.getString("f_size"));
System.out.println(rs.getString("trans_date"));
System.out.println(rs.getString("f_access"));
including the column "f_access" again...
but it gives me the following error
java.sql.SQLException: [Oracle][ODBC]Invalid column number <1>.
thanx Mike for the response
I hope that this will solve my problem...
22 years ago
As told by u I tried the following code:-
<html>
<head>
<script language="JavaScript">
javascript:window.history.forward(1);
</script>
</head>
<body>
<%
session.invalidate();
response.sendRedirect("Login.jsp");
//or use <jsp:forward page="Login.jsp">
//or use <jsp:include page="Login.jsp">
%>
</body>
</html>

but still it goes back....which is the appropriate method to implement this?
22 years ago
I'm working on application in JSP...now when ever the user on the browser requests the information from the webserver then he gets that..but when he updates some information to the server and returns to the previous page to see the upadtion he gets the previous old data prior to updation..its only after manually refreshing the page from browser's button he can view the real data after updation...so please can u tell me the way of automatically refreshing the pages...so that whenever user goes to the page to see the updation..he doesn't see the old data but the new data...
I hope I had made myself clear..
thanx in advance
22 years ago
JSP
I'm making an application in JSP for updating the files to and downloading the files from the database..When I download the files from the database then the file which opens contains some garbage data in the first line and overwrites the original data..
so can anybody tell me the solution for this?
thanx in advance for this..
22 years ago
JSP