• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HttpServletResponse response

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.)
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic