473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

filename, directory name, or volume label syntax is error in the try catch

Dear Sir
when i am getting the value from properties file the
the path showing http://127.0.0.1:81/help/Subject of Issue.txt which is right.
But in jsp in try block when pass SubjectofIssue path that time it is
showing SubjectofIssue););//http:\127.0.0.1:81\help\Subject of Issue.txt

So the error comming in jsp page.

Please look at my error log.

SubjectofIssue http://127.0.0.1:81/help/Subject of Issue.txt
stdout: exception in getting connectionhttp:\127.0.0.1:81\help\Subject of Issue.txt (The filename, directory name, or volume label syntax is incorrect)




Could you please tell me the reason why such an error i am geting in jsp inside the tryblock.

Thanks in Advance.
Regards
Sumanta

quote:
Expand|Select|Wrap|Line Numbers
  1.  
  2. --------------------------------------------------------------------------------
  3.  
  4. ItsPropertiesNT.properties
  5. ---------------------------
  6. SubjectofIssue=http://127.0.0.1:81/help/Subject of Issue.txt
  7.  
  8. x.jsp
  9. --------------------------
  10. <%
  11. String SubjectofIssue = null;
  12. ResourceBundle bundle = null;
  13. if(Config.serverType != null && "NT".equals(Config.serverType))
  14. {
  15. bundle = PropertyResourceBundle.getBundle("ItsPropertiesNT");
  16.  
  17. }
  18.  
  19. if(bundle != null)
  20. {
  21. SubjectofIssue = bundle.getString("SubjectofIssue");
  22. out.println(SubjectofIssue="+SubjectofIssue);//http://127.0.0.1:81/help/Subject of Issue.txt
  23. }
  24.  
  25. %>
  26. <%
  27. try{
  28. System.out.println("SubjectofIssue"+SubjectofIssue);//http:\127.0.0.1:81\help\Subject of Issue.txt
  29. String theBR;
  30. File fin=new File(SubjectofIssue);
  31. FileReader fr=new FileReader(fin);
  32. BufferedReader br=new BufferedReader(fr);
  33. theBR=br.readLine();
  34. String[] theSplit=theBR.split(",");
  35. for(int i=0;i<theSplit.length;i++)
  36. out.print("<option value=\"" + theSplit[i] +
  37. "\">" + theSplit[i] + "</option>");
  38. // out.print("</select>");
  39.  
  40. }catch(Exception Ex){
  41. System.out.println("exception in getting connection"+Ex.getMessage());
  42. }
  43. %>
  44.  
Jan 2 '09 #1
7 11554
JosAH
11,448 Expert 8TB
I don't quite understand your question but that url most certainly isn't a valid file name; you should use the URL and/or URLConnection classes for that, not the File class.

kind regards,

Jos
Jan 2 '09 #2
Dear JosAH Sir,
You are right.Means i read the data from properties file.And kept it in a variable.

Instead of hard coded that in the file
File fin=new File("C:/Project/Sun/https-ITS/webapps/https-ITS/help/Subject of Issue.txt");//Which is getting right value.

But if i am using File fin=new File(SubjectofIssue);//SubjectofIssue which i store the properties file data which given error.


Could you please sir tell me the syntax how we use URL here
File fin=new File(URL);

Please sir,Advise me for the needful.

Thanks in Advance.

Regards
Sumanta
Jan 2 '09 #3
JosAH
11,448 Expert 8TB
But if that file is stored on a local file system, why don't you simply change your ItsPropertiesNT.properties file? You don't need a URL for that. A file name is enough.

kind regards,

Jos
Jan 2 '09 #4
Dear JosAHSir,
According to your advise in the properties file

ItsPropertiesNT.properties
---------------------------
SubjectofIssue=Subject of Issue.txt

Now in jsp
SubjectofIssue = bundle.getString("SubjectofIssue");//It is getting the path
But if we pass the path in the file it is not working.
File fin=new File(SubjectofIssue);


Could you please advise for the needful.

Thanks in Advance.

Regards
Sumanta Panda
Jan 7 '09 #5
r035198x
13,262 8TB
What happens if you specify the full path of the file in your properties file instead of just the file name? Remember the JSP runs in the webapplication's context. You need to get to the servlet context first which in your case is "C:/Project/Sun/https-ITS/webapps/https-ITS". Then you need to give the path including the folder where you have put it, which is "/help/Subject of Issue.txt"
Jan 7 '09 #6
Dear r035198x Sir,
I agreed it is working.But if it is in our local machine then it will work.
Suppose if we keep the file in server machine then how it will work.
Could you please advise me for the needful.
Thanks in advance.

Regards
Sumanta Panda.
Jan 7 '09 #7
r035198x
13,262 8TB
Om the server machine you no longer have the path "C:/Project/Sun/https-ITS/webapps". You need to first get the path where the jsps and servlets are running from and then get the path to your file from there. This path is (sometimes) called the servlet context. To get it you use the utility method config.getServletContext(). Then with the context you simply call the method getRealPath(String path) to get the required path. So in your JSP you should do
Expand|Select|Wrap|Line Numbers
  1. config.getServletContext().getRealPath(pathFromPropertiesFile);
  2.  
In the properties file you now simply store the path as "/help/Subject of Issue.txt".
Jan 8 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Trevor | last post by:
Also posted in general ASP.NET forum. System.IO.IOException: The filename, directory name, or volume label syntax is incorrect. I have hit a problem for which I can find no solutions. Has...
1
by: Krazitchek | last post by:
Hi, i check all directories on a disk but an error occurs when i try to enter in the "System Volume Information" directory. Is there a way to "jump" this directory without to check the name of...
2
by: Technical Group | last post by:
Friends, Can anybody help me out by sending a piece of C# code showing how to add an active directory user to a particular user group? If the group does not exist, then create it. Thanks in...
8
by: Dmitry Klymenko | last post by:
Do exists a way to detect a volume label of a disk? I've found the way to do this using WMI (System.Management) or winapi function. The second solution is principal non-portable in future, the first...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
22
by: rtilley | last post by:
# Spaces are present before and after the XXX filename = ' XXX ' new_filename = filename.strip() if new_filename != filename: print filename Macs allow these spaces in file and folder...
8
by: Michael Robertson | last post by:
I'm having trouble opening a file in linux, whose path has spaces in it. $ mkdir my\ test $ echo test my\ test/test.txt $ python Exception Exception but yet...
1
by: =?Utf-8?B?QnJpYW4=?= | last post by:
I want to convert a filename to it's equivalent unc filename. First, is there a C# call that i can use that will do it directly? If not then I will look at the Directory.FullPath() of a file and...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.