• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uploading a file?

 
mallikarjun dontamsetti
Ranch Hand
Posts: 246
Firefox Browser Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 3
    Java Netbeans IDE Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 246
    Firefox Browser Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    x.printStackTrace(); is line number 59
     
    mgupta gupta
    Greenhorn
    Posts: 3
    Java Netbeans IDE Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 246
    Firefox Browser Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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..?
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic