wood burning stoves 2.0*
The moose likes JSP and the fly likes class not detected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "class not detected" Watch "class not detected" New topic
Author

class not detected

neelesh kumar
Greenhorn

Joined: Oct 03, 2013
Posts: 29
i have a class file named crypto which is packaged in com.test.util folder placed in the classes folder of WEB-INF......but when i use this class crypto in my jsp code by importing that package as follows:
<%@ page import="com.test.util.*"%>
Crypto.encrypt(in, outS);

it throws an error that Crypto cannot be resolved....What to do???
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
Is the class called Crypto or crypto?
neelesh kumar
Greenhorn

Joined: Oct 03, 2013
Posts: 29
its called Crypto...i even archived it into a jar file and placed it in the lib folder of WEB-INF..still doesnt work...here is my complete jsp code though :

<%@ page import="com.test.encript.util.*"%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.io.*" %>

<%@ page import="org.apache.commons.fileupload.servlet.*"%>
<%@ page import="org.apache.commons.fileupload.disk.*"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<center>
<table border="2">
<tr>
<td>
<h1>Your files uploaded </h1>
</td>
</tr>
<%
String uploadPath = "C:/UploadedFiles/" + (String)session.getAttribute("username") + "/decript"+"/";

boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart) {
} else {
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = null;
try {
items = upload.parseRequest(request);
} catch (FileUploadException e) {
e.printStackTrace();
}
Iterator itr = items.iterator();
while (itr.hasNext()) {
FileItem item = (FileItem) itr.next();
if (item.isFormField()) {
} else {
try {
String itemName = item.getName();
File savedFile = new File(uploadPath + itemName);
item.write(savedFile);


} catch (Exception e) {
e.printStackTrace();
}
}
}
//chanchal
// String uploadPath = "C:/UploadedFiles/" + (String)session.getAttribute("username") + "/decript/";
//out.println(uploadPath);

File f = new File(uploadPath);
File[] files = f.listFiles();
for(int i=0;i<files.length;i++){
FileInputStream in = new FileInputStream(files[i]);
File eFile = new File("C:/UploadedFiles/" + (String)session.getAttribute("username") +"/"+files[i].getName());
FileOutputStream outS = null;
outS = new FileOutputStream(eFile);
Crypto.encrypt(in, outS);
try{
outS.close();
in.close();
files[i].delete();
}catch(Exception e){
e.printStackTrace();
}

// String name=files[i].getName();
//String path=files[i].getPath();
}


}
response.sendRedirect("upload-download.jsp");
%>
</table>
</center>
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
Is the package "com.test.util.* or "com.test.encript.util.*"?
neelesh kumar
Greenhorn

Joined: Oct 03, 2013
Posts: 29
its com.test.ecnript.util.*
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

To being with, you shouldn't have all this Java code in a JSP at all. It should be in a Java class. Scriptlets within a JSP have been obsolete and discredited fro over 12 years.

I'd recommend you refactor your code to put the Java code in a servlet or other Java class.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class not detected