• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Downloading a jar file

 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know what will the DD look like in this code (in the attachment)
Filename: 1.bmp
Description:
File size: 750 Kbytes
[Download 1.bmp] Download Attachment
 
Paul Clapham
Sheriff
Posts: 21117
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's "the DD"?

And I really don't want to download 750 kilobytes of code. It would be better if you produced a small example of what you were asking about and just posted it on the forum. Note the "Code" button which will format it nicely for you.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64964
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please follow Paul's instructions. Posting code as images means that it cannot be searched. Please post code in the reply using code tags.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yay to broadband. But yes you should just have posted the five lines of code inside a code tag.

The only place I have come across DD is with EJB's - So yes not sure what your question is. In fact the code looks stand alone - nothing special needs to be done. Rephrase your question - if there is one?
 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DD is Deployment Descriptor...sorry for my laziness...here's the code from HFSJ chap-4

 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said before whats the DD doing in a Servlet application. Surely you mean the web.xml?
As I said before (Pun Intended) nothing special needs to be done for this code.
 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops ya web.xml
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64964
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The web.xml is the deployment descriptor.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:The web.xml is the deployment descriptor.


Ops my bad - That's what I get for working on so many technologies...
I still don't get how all of this relates to the question though.

(also gets up my 100th post out here )


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64964
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that we've got the terminology down pat, I too have no idea what the question is.
 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to know what will be the context param in the DD
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64964
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set up a context parameter to be anything you want. What does that have to do with the code you posted? (Do you really not use indentation in your code?)
 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok guyz ....i want to to download a jar file.So how to go about it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64964
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You click on a link to it.

I mean really -- what does your question have to do with the deployment descriptor? And what does it have to do with context parameters?

Your question is all over the place and it's hard to know what you are asking. My advice is to sit back, organize your thoughts, and ask the question in a cogent fashion. Starting with what specific issues you are having with the code.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankitt Gupta wrote:ok guyz ....i want to to download a jar file.So how to go about it.


Well the HFSJ chap-4 explains this pretty clearly.

1. They pretty clearly mention that if all you need is to let the user download a Jar file - Just give him a direct link to it. You know just put the jar file in the application directory - say test.jar in the application sampleApps and the link to it will be http://localhost:8080/sampleApps/test.jar

2. The chap also pretty clearly states (if I remember correctly - I read the book a year ago) that the only reason you should use getResourceAsStream is if you need to do something really out of the box say generate a on the fly music stream or jar or whatever. Really this code is just an example explaining how to use getResourceAsStream. There is nothing special that goes into the DD (Deployment descriptor) - beside you regular servlet mapping. So all you need in your DD is the mapping for -- CodeReturn and it works.
 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey sam it's giving an error The requested resource () is not available.

i'm using netbeans 6.5.I put the jar file in web-inf folder.I think it is unable to find the jar file
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64964
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as a web-inf folder. It's WEB-INF. Please take care not to waste people's time with careless mistakes like this. Please read this for more information.

In any case, you cannot serve anything out of the WEB-INF folder. Place it somewhere else within the web application.
 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think you are over reacting Bear .It is just in lower case thats it.Its understandable.

I have tried in every folder it's not working
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64964
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankitt Gupta wrote:i think you are over reacting Bear .It is just in lower case thats it.Its understandable.

No, I'm not and it's not. If you look through the history of this forum I can't tell you how many times that assumption has been made and people have wasted an enormous amount of time trying to diagnose a problem when the real problem was that the WEB-INF folder was improperly cased. Please be precise.

I have tried in every folder it's not working

Well, it's not going to work out of WEB-INF, even properly cased, or any folder under WEB-INF. If you place it within the web application outside of WEB-INF and give it the correct URL, it will work.

Pick a place for it and tell us where it is. The show the URL you think should be addressing it. This should be a very simple thing to do.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankitt Gupta wrote:hey sam it's giving an error The requested resource () is not available.


Did you consider posting the actual error? Requested resource could mean a lot of things ... give us the WWW if you really want some help,
a. Where do you get the Error (on the console?)
b. What is it that you are doing when you get the error? (do you get the error when you hit a link?)
c. and what the error is (details .. at least a few relevant lines)?

Also we could have nailed down to the problem quicker if you had mentioned this error before instead of taking the indirect route of asking about the deployment descriptor...
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sam, it is just a simple HTTP 404 'Page Not Found' error.

The URL does not point to any public resource and is also not covered by any url-pattern in the web.xml's. With other words, either the URL is plain wrong, or the resource is not there where you think it is. That's all. There are no special causes for this.

To the topicstarter, anything is already been said, but I'll repeat it:
1) If you place files in public webcontent (NOT in /WEB-INF, but just next to all JSPs and so on), you can just link to it, exactly the same way as you link JSPs.
2) If you place files outside public webcontent (e.g. in /WEB-INF or completely outside the webapp somewhere at the local file system), you need to create a Servlet which reads the file from disk and writes it to the outputstream of the response. Then you can link to the url-pattern of the Servlet, along with some request parameter or pathinfo denoting the unique file.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:Sam, it is just a simple HTTP 404 'Page Not Found' error.

The URL does not point to any public resource and is also not covered by any url-pattern in the web.xml's. With other words, either the URL is plain wrong, or the resource is not there where you think it is. That's all. There are no special causes for this.


Yep I got that part.

What I did not get (before) is,

a. If there is a problem with the jar file being in the wrong location - which should throw an exception some where on the console (right? - though i guess it would not be requested resource () is not available.) or

b. if the link that points to "CodeReturn Servlet" itself is incorrect (you know the usual - typo in the URL, incorrect mapping in the web.xml) which would cause an error on the browser page (resource not found, correct?)

On the solution front I am completely with you (Bauke)
 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for being patient with me.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic