• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error while trying to download Excel file using java

 
Nash kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to download excel file from server after clicking on a link. I have written the below JSP and Servlet code. JSP and Servlet are both in the same folder. I get the error "The requested resource (/BulkAccess/Download) is not available" after clicking on hyperlink to download the excel file. Any help?

JSP CODE


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your href value should be a server-realtive URL that starts with the context path. See the JspFaq for more information.
 
Nash kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please type the server-realtive URL for href value ? Thank you. It will be helpful.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a part of the JspFaq that you did not understand? Which part? I'll make sure it is clarified.
 
Nash kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what I tried from FAQ.. Correct me if I am doing anything wrong.

Changed the JSP Code to :





Then got the below error.


javax.servlet.ServletException: Wrapper cannot find servlet class Download or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)


root cause

java.lang.ClassNotFoundException: Download
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the relevant part of the stack trace:

What does that tell you?

Hint: perhaps the servlet is incorrectly configured?
 
Nash kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First I tried copying the servlet to the same folder as JSP file that didn't work. Getting the same class not found error .

Now, I tried creating a package and then changing the servlet mapping to below code. But not luck yet.

com.abc.bulk is the package name.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you place the class file?
 
Nash kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
com.abc.bulk package. This contains the servlet class file. (Download.java)
 
Deepak Vishwakarma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nash kumar wrote:I am trying to download excel file from server after clicking on a link. I have written the below JSP and Servlet code. JSP and Servlet are both in the same folder. I get the error "The requested resource (/BulkAccess/Download) is not available" after clicking on hyperlink to download the excel file. Any help?

JSP CODE





<body>
<a href = "http://localhost:8080/myApp/Download">Download</a>
</body>
you can use this one , its work hope you got it
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a good idea. Using and absolute URL is a poor practice. And it won't solve the issue in any case.
 
Bharath Kannan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear Bibealut:
Please suggest any other alternative rather than using 'absoulte URL'. Ive a servlet defined for such a download, though use the absolute URL in the client html.
Thanks
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.
Did you go through the JspFaq which Bear suggested to the OP?
 
Ishan Pandya
Ranch Hand
Posts: 226
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nash kumar wrote:com.abc.bulk package. This contains the servlet class file. (Download.java)


Are you sure about this statement?
I see some mismatch in .java file and .class file
you sould have .class file in com.abc.bulk
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic