473,397 Members | 1,972 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,397 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 11557
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.