aspose file tools*
The moose likes Servlets and the fly likes Uploading a file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Uploading a file?" Watch "Uploading a file?" New topic
Author

Uploading a file?

mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 243

Hi,
I am getting problem when i try to upload the file in jsp. In my form i have to insert data into two tables. I have to set data from jsp to bean class in servlet. the second table has file uploading also so i have written the code like this

servlet:









when i submit form i am getting this exception:


  • java.lang.NullPointerException
    at project.UploadServlet.doPost(UploadServlet.java:59)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)


  • please help me to in this .........
    thanks in advance
    mgupta gupta
    Greenhorn

    Joined: Nov 09, 2011
    Posts: 3

    What is line number 59 in your UploadServlet.java. Check 59th line in UploadServlet as the exception is at this line only
    mallikarjun dontamsetti
    Ranch Hand

    Joined: Mar 18, 2011
    Posts: 243

    x.printStackTrace(); is line number 59
    mgupta gupta
    Greenhorn

    Joined: Nov 09, 2011
    Posts: 3

    So you have to debug the corrospinding try block, there must be some variable that is null and you are doing some operation overnull i.e. null.doSomeOperation which is causing NullPointerException
    mallikarjun dontamsetti
    Ranch Hand

    Joined: Mar 18, 2011
    Posts: 243

    I found the solution for null pointer exception. in my jsp form page i am giving "hidden" action name

    and i am getting it in my servlet like this

    based on this value i am calling the particular methods. It work's for me in the previous applications but not in this one.
    I replaced my hidden action with form action like <form action="sevletpath?Action=xx" ...> then it works fine why this happened..?
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Uploading a file?