This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes HttpServletResponse response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpServletResponse response" Watch "HttpServletResponse response" New topic
Author

HttpServletResponse response

Mike Lesman
Greenhorn

Joined: Feb 23, 2012
Posts: 2
Hello,
I need to download excel file from our SharePoint web site, enter some values there and upload it back. I never did this type of work before – it is my second java project in general, and I am goggling a lot. In the snippet below I am trying just to download “A Test Counts.xlsl” file.


When I run this class from eclipse, I get the following

Exception in thread "main" java.lang.NullPointerException
at com.tests.WebFile.main(WebFile.java:17)

I realize that value of the response variable is null and hence the exception. Tutorials that I read

http://www.javaworld.com/javaworld/javatips/jw-javatip94.html?page=1
http://www.mkyong.com/java/how-to-download-file-from-website-java-jsp/

introduce response as a given variable not elaborating how it get its value. What exactly should be done here to make it work?
Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information. Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.

I've gone ahead and added the code tags for you. See how much easier the code is to read? (And makes it unnecessary to add your own line numbers.)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

Servlets aren't executed like "normal" Java programs that have a main() function. Rather, they are bundled into a web application that is then executed by a servlet contains such as Tomcat, Webshpere, Glassfish, and so on.

If you need to write and execute a servlet, these are concept that you will need to learn. I recommend picking up a good book (Head First Servlets and JSP one is popular) and prepare to learn a lot.

On the other hand, based upon what you say you are trying to accomplish, I think you may be heading down the wrong path thinking that you need a servlet.

Can you expand on your actual goal?
Mike Lesman
Greenhorn

Joined: Feb 23, 2012
Posts: 2
My actual goal is to open the spreadsheet from the company’s web site, enter values (number of test cases for each product) in the spreadsheet and save it where it was on the web site. I already wrote java code that updates checked out code on my development box from subversion, calculates number of test cases for each product, finds the rows correspondent to the titles of the products in the spreadsheet, and enters those values in the spreadsheet saved on my development box. In reality, I have to open spreadsheet from the company’s website, not the copy that I saved locally, and as you mentioned some direction to head to would be helpful. (The one that I tried was obviously not the right one for this particular task).
Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Sharepoint? I believe that it exposes a collection of web services which allow programs to do that sort of thing. Probably you can download from Sharepoint as if it were an ordinary web site, but not upload. Although I have no experience with doing that.
 
GeeCON Prague 2014
 
subject: HttpServletResponse response