• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

why this type of error coming?

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here i write one servlet class like this,inorder to download file:

DL.java(servlet)
package sntechsolutus.com;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class DL extends HttpServlet{
public void service(HttpServletRequest request,HttpServletResponse response)throws IOException{
PrintWriter out=response.getWriter();
String originalFileName=request.getParameter("fileDisp1");
}
public void doGet(HttpServletRequest request,HttpServletResponse response)throws FileNotFoundException,IOException{
String originalFileName=request.getParameter("fileDisp1");
response.setContentType("application/download");
response.setHeader("Content-Disposition", "attachment; filename=\""+originalFileName+"\"");
FileInputStream fin = new FileInputStream(originalFileName);
int size = fin.available();
response.setContentLength(size);
byte[] ab = new byte[size];
OutputStream os = response.getOutputStream();
int bytesread;

do{
bytesread = fin.read(ab,0,size);
if(bytesread >-1)
os.write(ab,0,bytesread );
}while(bytesread >-1);
fin.close();
os.flush();
os.close();
}
}


i mapped this in web.xml like this:

< servlet-name<dnload</servlet-name<
<servlet-class<DL</servlet-class<
<servlet-name<dnload</servlet-name<
<url-pattern</DL</url-pattern<

and in in jsp i write like this inorder to map the url:

<script type="text/javascript"<
function call(){
document.testForm.action="<%=request.getContextPath()%<" +"/DL";
document.testForm.submit();
}
</script<

<a href="<%=dispValue%< onklick="javascript:call()"" target=_blank<<%=dispValue%</a<

now when i am trying to execute it is giving error that:
"The requested resource (/ajay/) is not available.",however that ajay folder is there in webapps directory.

can any one help?
Regards,
Sreelakshmi.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There may be other problems, but in the <servlet-class> you need to use the fully qualified class name of the servlet, including the package name.

It's also helpful to look if there are error messages in the server log files; I bet there are.
 
sreelakshmi kolla
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Ulf,
now it is giving an exception like "org.apache.jasper.JasperException: Cannot find ActionMappings or ActionFormBeans collection"
please help me
Regards,
Sreelakshmi.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See question 12 of the JavaRanch Struts FAQ
 
sreelakshmi kolla
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i modified all the files .now its working.i used same DL.java filedownload the files.i made a slight modification here,i.e in JSP page:
<a href="/DL"?FileName="<%=fileDisp1%>"> <%=fileDisp1%> </a>

now when i click on that particular link,it is displaying like this:

Error:400
type Status report
message /ajay/DL
description The requested resource (/ajay/DL) is not available.

where i made wrong?

Regards,
Sreelakshmi
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem may be in the entries in your web.xml file. They should look something like this:

The important thing here is the url-pattern. You must have the "/*" at the end to indicate that other characters may follow the "/DL".
reply
    Bookmark Topic Watch Topic
  • New Topic