Opening a file from Servlet
Hi,
I`m trying to open a file from Tomcat Servlet init method but it fails with java.io.FileNotFoundException: test.properties (The system cannot find the file specified).
The code is:
File f = new File("test.properties");
DataInputStream is = new DataInputStream((new FileInputStream(f)));
System.out.println(is.readLine());
is.close();
test.properties is in /WEB-INF/classes directory.
What is the classpath for a web app and is it possible to adjust it?
Thanks,
vs
What is the error saying???
Are you sure the file location is right?
MeTitus
Similar Messages
-
URGENT HELP- opening a file from servlet
I posted this message in other forum by mistake. Please help me. Wish I could award you 1000 duke dollers if had. It would be great help if somebody can help me out.Thanks
http://forum.java.sun.com/thread.jsp?forum=12&thread=383418&tstart=0&trange=15Thanks.
When I do that, it is disabling the radio button which allows the user to open it from the browser anyway I could solve the problem using the following code. Thanks for your response. I appreciate it.
res.reset();
res.resetBuffer();
res.setContentType("text/plain");
// res.setHeader("Content-Disposition","inline; filename=" +urlPdf );
res.setHeader("Content-disposition","attachment; filename" +urlPdf );
res.setHeader("Cache-Control","no-cache"); //HTTP 1.1
res.setHeader("Pragma","no-cache"); //HTTP 1.0
res.setDateHeader ("Expires", 0); //prevents caching at the proxy server
res.setHeader("Cache-Control","no-store"); //HTTP 1.1Thanks
-Sreekanth Varidhireddy -
PROBLEM while using URL in order to open a file from a servlet
Hi,
I am having a problem while trying to open a file from my servlet by using URL connection. Following is my code sample. what happens is when I first run my project it opens the file but after that when I rerun it again and again it sometimes opens it and sometimes not. if it can't open it it gives an error saying "the file is damaged and couldn't be repaired". I don't get any exceptions. if you guys can help me I will appreciate it so much... thanks.
here is my code :
URL url = new URL("http://demobcs.ibm.com:81/test.pdf");
resp.setContentType(getContentType("http://demobcs.ibm.com:81/test.pdf"));
ServletOutputStream sos = null;
BufferedInputStream bis = null;
try {
sos = resp.getOutputStream();
} catch (Exception e) {
System.out.println("exception !!!!");
e.printStackTrace();
System.out.println("burada2");
try {
byte[] bytes = new byte[4096];
//bis = new BufferedInputStream(conn.getInputStream());
DataInputStream in = new DataInputStream(url.openStream());
//DataInputStream in = new DataInputStream(conn.getInputStream());
bis = new BufferedInputStream(in);
int j;
while ((j = bis.read(bytes, 0, 4096)) != -1) {
try {
sos.write(bytes, 0, 4096);
System.out.println("file is being read ...:");
} catch (Exception e) {
e.printStackTrace();
in.close();
bis.close();
//sos.close();
} catch (Exception e) {
System.out.println("exception :"+e.toString());
e.printStackTrace();
}You are writing (<filesize> mod 4096) bytes of crap at the end of the file. Use your variable j instead for the number of bytes to write in your loop.
-
Hi,
I need some help.
Product=weblogic5.1.0
Revision=(Release Level)=
Problem Description=
I am doing cluster of weblogic server, I have no problem to set up the
cluster and to run servlet and EJB examples.
However, on my command line for startcluster I got a lot of message as
followed:
Fri Aug 18 11:31:44 EDT 2000:<E> <MulticastSocket> Multicast socket receive
error: java.lang.RuntimeException: I/O error opening JAR file from
file:/D:/weblogic/mycluster/server86/tmp_deployments/ejbjar-17327.jar
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
at weblogic.boot.ServerClassLoader.deploy(ServerClassLoader.java,
Compiled Code)
at
weblogic.cluster.AnnotatedServiceOffer.expandClassPath(AnnotatedServiceOffer
.java, Compiled Code)
at
weblogic.cluster.AnnotatedServiceOffer.readObject(AnnotatedServiceOffer.java
, Compiled Code)
at
weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
jectInputStreamBase.java, Compiled Co
de)
at
weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
treamBase.java, Compiled Code)
at
weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
tStreamBase.java, Compiled Code)
at
weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
eamBase.java, Compiled Code)
at
weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
treamBase.java, Compiled Code)
at
weblogic.common.internal.WLObjectInputStreamBase.readArrayList(WLObjectInput
StreamBase.java, Compiled Code)
at weblogic.cluster.StateDump.readObject(StateDump.java, Compiled
Code)
at
weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
jectInputStreamBase.java, Compiled Co
de)
at
weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
treamBase.java, Compiled Code)
at
weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
tStreamBase.java, Compiled Code)
at
weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
eamBase.java, Compiled Code)
at
weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
treamBase.java, Compiled Code)
at weblogic.cluster.TMSocket.execute(TMSocket.java, Compiled Code)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
Code)
The message freshed about every 20 seconds.
Another question, I used a iplanet web server as a proxy server with a
cluster of two weblogic servers pluged in, although I set
weblogic.properties to round-robin, however, when I run a fibonacci servlet,
it does not do the round-robin. It always go to one machine for a lot of
times. Any idea?
Thank you for your help.
Tom
May i presume that your cluster is configured on a shared file system?.
I have seen this problem only if you cluster is configured on different machines
and if the directory structure is not identical.
let us know..
Kumar
Cameron Purdy wrote:
> First, update to SP4 (or SP5 if it is out now). Second, follow the cluster
> instructions on setting up deployments for a cluster. The only
> implementation that I have used is the single shared location that all the
> servers load from.
>
> --
>
> Cameron Purdy
> http://www.tangosol.com
>
> "Tom Gan" <[email protected]> wrote in message
> news:[email protected]...
> > Hi,
> > I need some help.
> >
> > Product=weblogic5.1.0
> > Revision=(Release Level)=
> > Problem Description=
> > I am doing cluster of weblogic server, I have no problem to set up the
> > cluster and to run servlet and EJB examples.
> > However, on my command line for startcluster I got a lot of message as
> > followed:
> > Fri Aug 18 11:31:44 EDT 2000:<E> <MulticastSocket> Multicast socket
> receive
> > error: java.lang.RuntimeException: I/O error opening JAR file from
> > file:/D:/weblogic/mycluster/server86/tmp_deployments/ejbjar-17327.jar
> > java.util.zip.ZipException: error in opening zip file
> > at java.util.zip.ZipFile.open(Native Method)
> > at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
> > at java.util.zip.ZipFile.<init>(ZipFile.java, Compiled Code)
> > at weblogic.boot.ServerClassLoader.deploy(ServerClassLoader.java,
> > Compiled Code)
> > at
> >
> weblogic.cluster.AnnotatedServiceOffer.expandClassPath(AnnotatedServiceOffer
> > .java, Compiled Code)
> > at
> >
> weblogic.cluster.AnnotatedServiceOffer.readObject(AnnotatedServiceOffer.java
> > , Compiled Code)
> > at
> >
> weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
> > jectInputStreamBase.java, Compiled Co
> > de)
> > at
> >
> weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
> > treamBase.java, Compiled Code)
> > at
> >
> weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
> > tStreamBase.java, Compiled Code)
> > at
> >
> weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
> > eamBase.java, Compiled Code)
> > at
> >
> weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
> > treamBase.java, Compiled Code)
> > at
> >
> weblogic.common.internal.WLObjectInputStreamBase.readArrayList(WLObjectInput
> > StreamBase.java, Compiled Code)
> > at weblogic.cluster.StateDump.readObject(StateDump.java, Compiled
> > Code)
> > at
> >
> weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(WLOb
> > jectInputStreamBase.java, Compiled Co
> > de)
> > at
> >
> weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjectInputS
> > treamBase.java, Compiled Code)
> > at
> >
> weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObjectInpu
> > tStreamBase.java, Compiled Code)
> > at
> >
> weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectInputStr
> > eamBase.java, Compiled Code)
> > at
> >
> weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjectInputS
> > treamBase.java, Compiled Code)
> > at weblogic.cluster.TMSocket.execute(TMSocket.java, Compiled Code)
> > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
> > Code)
> >
> > The message freshed about every 20 seconds.
> >
> > Another question, I used a iplanet web server as a proxy server with a
> > cluster of two weblogic servers pluged in, although I set
> > weblogic.properties to round-robin, however, when I run a fibonacci
> servlet,
> > it does not do the round-robin. It always go to one machine for a lot of
> > times. Any idea?
> > Thank you for your help.
> > Tom
> >
> >
> >
-
Hi,
I'm running a servlet and wants to open a URL for a file, how do I do that ?
(To get the same effect as if I open the file from a browser)
thanks in advance..
..Per
If you mean to read the contents of a URL, then see URL.getConnection. If
you mean to download a file to a browser, then search this newsgroup for
"download".
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com
+1.617.623.5782
WebLogic Consulting Available
"Per Lovdinger" <[email protected]> wrote in message
news:3a9a7650$[email protected]..
> Hi,
>
> I'm running a servlet and wants to open a URL for a file, how do I do that
>
> (To get the same effect as if I open the file from a browser)
>
> thanks in advance..
> ..Per
>
>
-
I am trying to open CR2 files from a Cannon EOS 1DX camera in Photoshop CS6 and I have already updated the Camera Raw Plug in but Photoshop is still giving me the cannot open files dialog box? Help?
Canon 1DX support was added to ACR in version 6.7, 7.1. An updated CS6 should be at level ACR 8.6. If your ACR is not at level 8.6 try using CS6 menu Help>Updates. If that does not install ACR 8.6 try downloading the ACR and DNG 8.6 converter and see if ACR 8.6 will install into your CS6.
Adobe - Adobe Camera Raw and DNG Converter : For Windows
Adobe - Adobe Camera Raw and DNG Converter : For Macintosh -
Is there a way to open Excell file from the server and display in the UI and save it back on to the
Hello there,
Is there a way to open Excell file from the server and display in the UI and save it back on to the server? (like showing xell file as a datagrid - add rows, columns etc.)Hi Mike,
Welcome you to the forum.
You may try:
SELECT * FROM MyDBNameHere.dbo.OUSR T0
Thanks,
Gordon -
Adobe Bridge CS6 (Mac) won't open .arw files from my Sony RX100. I was told to update Camera Raw to at least 7.2. I tried to download this but got a DNG Converter instead. Where is Camera Raw? (it does not show up in a search of my hard drive. There is a folder of camera profiles but no extension or plug-in with this name). How do I find out what version I have already? How do I get the correct version? . . . OR . . . is it the case that Bridge will never open Sony raw files directly and I will have to do a separate conversion process every time I want to use a raw file??. Can someone explain this?
Thanks.A Good samaritan answered this for me on another forum
How to update Camera Raw -
I cannot open a pdf file with aol e-mail. I went to preferences in Adobe Reader but did not know what to enter for Incoming IMAP and outgoing SMTP. I can open pdf files from windows explorer as I have associated .pdf files with adobe reader. My operating system is windows 7.
When I try to open the pdf file within aol e-mail I get a message: 'Your security settings do not allow this file to be downloaded'. I have not changed my security settings (Tools, Internet Options, security).Or http://helpx.adobe.com/acrobat/kb/pdf-browser-plugin-configuration.html
-
I have recently updated my CC programs to the latest version (CC2014) and now all of my files wont open by default into their respective programs, only if I open the program and go to file>open and open the file from there. How can I fix this?
I have tried 'Open with' and the version of the program now installed on my computer isn't even suggested as an option and when I browse for it, the file wont open with it anywayOn Windows (don't know about Mac), the latest version will always take over the file association, and become the default for indd files. It's impossible to change it.
But there is a plugin for ID that makes this possible. Never tried it myself.
https://www.rorohiko.com/wordpress/downloads/lightning-brain-soxy/ -
The problem i am having is when i go to open a file from the menu bar that as "FILE" is blackcolor
the problem i am having is when i go to open a file from the menu bar that as "FILE" is all black in color and i cant see what i'm picking how do i change that so i can see what i'm picking
Is that Photoshop? Depending on the version you could try to change the Color Theme (Edit | Preferences | General | Appearance).
If that does not help, you may have a better chance to get a useful answer if you ask in the Photoshop or Photoshop Elements forum. -
my windows(8.1 64bit) partition is read only from the mac(yosemite) side of things. Anybody have a clue on how to fix this? Also, slightly frustrating as well, windows crashes every time I attempt to open a file from the mac partition.
All Office applications will also try to open a temporary work file in the same location as the source file. This implies the source file directory also needs to be writable for this temporary file. Since the default HFS+ driver provides only read-only access, such temporary files will fail to open, and will cause the application to fail.
As a test copy the file you want to edit, say an Excel spreadsheet from the OSX file system to the C: drive on the Windows side and try to open it. If you look in this directory, you should see two files, the source and a temporary file. You may have to force the temporary file to be opened on a read-write file system, by manipulating the folder for temporary files. -
Unable to open .chm file from a link in Weblogic 7.0
Unable to open .chm file from a link in weblogic server. But the same
jsp code works in Websphere
Sample Code :
<!-- < a href="JavaScript:window.navigate('help/manual.CHM')">
Linked Text</a> -->
The above link, works well in websphere. help is a folder that
resides in the server. But when i tried to execute the same in
Weblogic, some junk characters appeared . so i tried to direct the
link to Display.jsp and passed the path of the chm file as the
parameter. I cleared teh out buffer using out.clearBuffer() . i set
the content type to application/x-msdownload and also set the header
to content disposition.
Nothing worked .
I also tried another way.. That is the following
I even tried including the mime type
<mime-mapping>
<extension>chm</extension>
<mime-type>application/x-msdownload</mime-type>
</mime-mapping>
in the web.xml file. and still it doesnt work
Nothing Worked . What should i do ? I need immediate help to sort out
this issue. Can anybody help me
- AngelThis could be a Launch Services issue. The following article describes how to manually reset Launch Services — the notes at the bottom of the article also provide information about the side effects of deleting each of the files involved:
Resetting Launch Services
If you prefer using a cache cleaning utility instead of following the manual procedure described in the previous article, take a look at this other article for general troubleshooting and cache-cleaning procedures. Actually, you should also verify/repair the startup disk (not just permissions), as described there:
Resolving Disk, Permission, and Cache Corruption
The most appropriate utility for this particular problem probably is Tiger Cache Cleaner, but you may also want to consider other utilities, such as OnyX, or Cache Out X, which are free. Whatever utility you choose, be sure to read this first:
Side effects of System cache cleaning
As an example, this is how you should proceed with OnyX:
1. Quit all applications.
2. Launch OnyX and enter your administrator password.
3. Go to Maintenance > Reset and check LaunchServices database.
4. Un-check any other pre-checked options.
5. Click the Execute button.
6. Restart the computer.
BTW, if you’re running Mac OS X 10.4 (Tiger), as your profile indicates, it would have been more appropriate to discuss this in the Mail & Address Book - Tiger forum. If the discussion applies to both Mail 1.x and Mail 2.x, it doesn’t really matter, but it’s difficult to know that in advance. -
Excel 2008 wont open excel files from at WHS network share.
hi all
i have a strange problem here, i own a mac mini the 2.53ghz model bought a month ago, and a macbook (the white model) also bought a month ago, both running all the latest software updates, and office 2008 for mac, with all the latest updates
on the mac mini, i can´t open any excel documents that are stored on a shared folder on my windows home server, it just says
excel cannot open this file the file might have been damaged or modified from its original format
but when i try to open the same document on the macbook, it opens just fine?
i have tried to remove office 2008 and reinstall it on the mac mini, but that didnt help, and the strange thing is if i move the excel files, from my windows home server, to another windows home server, it opens just fine on the mac mini
i then suspected that it was the WHS that was ****** up, and deleted the account on the WHS where the folders were stored, rebooted the whs, and added the account again, but with the same result, the mac mini wont open the excel files, it will open word files, from the same folder.
and the macbook will still open both excel and word files, from the same folder?
i´m really confused now, and cant seem to pinpoint the error, and hope that someone can give me some pointers of where to look?
sincerely
Carsten Larsen
DenmarkYou're pobably better off posting your question on Microsoft's own forums for their Mac products, as it's their software you're having issue with:
http://www.officeformac.com/productforums -
I am trying to open PDF files from safari, but when I click on them they open in a separate window and the information is encrypted. Any ideas on how to get them to open them in Adobe? Any help please!
The pdf is loading as html code. If you save it, it will download as :
605124.pdf.html
Change the extension to .pdf
And it opens and works perfectly, I just tested it:
Use this link to download it automatically:
http://saladeaula.estacio.br/arquivo.asp?dir=00/1020624/605124.pdf&num_seq=59828 4
Maybe you are looking for
-
An answer regarding language and TOC
I am writing this little post because I know how frustrated you can become about small, small things. Things that make your book not entirely into your own language. I have posted questions in many threads - and finally got a solution for us who are
-
After installing Yosemite, Safari cannot open server webmail page : 'server unexpectedly dropped the connection". However emails coming to Mail ok.
-
Satellite C50-A CMOS password Reset
i have Satellite C50-A laptop and it was automaticaly loked on system startup & asking the cmos password.p/s guide me how to reset this password by steps.(i was tried ro remove cmos battery for 30~40 min but it is not working for me.) i have harware
-
Uploading stuff from ipod to computer
Hi I have two computers and i want to have my ipod on both computers. Is there a way that i can use itunes so that if i put my ipod on it it doesnt put stuff on it but it takes stuff off the ipod. Also, is there a way that when you update it it doesn
-
DW can't find new image?!
Hi all, I'm making changes in a website using DW, which include adding some new images. I edited the image using photoshop and move them into the file where all the images for the website are. Strange thing is the new images appear in the assets (als