Java HTML Web Scan - java

http://asprise.com/product/jia/html_javascript_scan_from_scanners.php
Need to use this and scan the document. Downloaded the program and run this code, it always says the error classNotfoundException: com.asprise.jia.ui.JiaApplet
I Placed the .java file in this structure
root folder
-Applet.html
-com
--asprise
---jia
----ui
-----JiaApplet.java
Please help me on this

Related

can I use .txt files in JAVA using VS code?

I am trying to access the text file in java and the code I have works in other IDEs but in VS code it keeps saying File Not Found - (produced from my exception handling)
I can't find anything about how to access text files with VScode. Is this possible please and does anyone know how?
I have tried to create the file in VScode with the new text file option and also by loading a pre-existing file and get the same result each time
Place the .txt file in the project root directory so that the code reads to the file location. As shown below
If the file is not with the project, use absolute paths in the code.

unable to find servlet(.java) files converted from jsp

I am using eclipse luna and tomcat version 7. I have written few jsp files and executing them on tomcat easily. I have read that jsps are converted into servlets at run time and you can locate them in tomcat/work/catalina/localhost/project name and further. My project name is quizilla and there exist a folder named quizilla-1.0-SNAPSHOT, but this folder is empty. What is the reason and where can i find those .java files. I have attached the screen shot of the folder as wellAs I am in right directory in search of my java files, but the folder is empty. So what should i do
You are using Tomcat from Eclipse, so the work directory is:
projectworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
or something like that (if you haven't changed the Server configuration via Eclipse).
Add
<%=getClass().getResource(getClass().getSimpleName() + ".class")%>
to one of your JSP pages to detect where Tomcat has generated the servlet.

Opening input file using java code in JSP

I am using JSP on NetBeans.
In the java code, I am trying to read data from a file. First I open the file by specifying its path.
Because my code runs on a server (GlassFish), I would like to have my file path independent of the machine where it runs. Therefore, I want to start the path with the folder name that contains the file which is saved on the root of the project directory. I tried so hard to achieve that but I couldn't.
I read online and I found this way, but it still doesn't work:
<%
//building the tree here.
GraphBuilder tree = new GraphBuilder("${pageContext.request.contextPath}\\src\\java\\Database\\OptimizedFullTermFile.pad");
%>
Can anyone help? Thank you.
Just read it from the classpath. Given that you're using the typical src folder representing the Java source code (the Java package/class structure), I assume that the file OptimizedFullTermFile.pad is placed in the Java package java.Database (eek, a capital in package name? lowercase it all). In that case, it's already in the classpath and thus you can just get it straight from there as follows:
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("java/Database/OptimizedFullTermFile.pad");
// ...
As to your failed attempt: the EL ${pageContext.request.contextPath} isn't ever going to work in a scriptlet. Even if it did, it's not the right thing, it returns the context path in the webapp URL which is absolutely not part of the local disk file system path, let alone the classpath. Using scriptlets is strongly discouraged since a decade, by the way.
See also:
getResourceAsStream() vs FileInputStream
Where to place and how to read configuration resource files in servlet based application?
You can try the following code to get your directory file in project from the following code.
this.getServletContext().getRealPath("")+[your file path in project web directory]

To get the root path of file in java

I am using eclipse Indigo IDE ..I am developing a jsp application (myProject) using eclipse in which i have a property file (myProject\webcontent\db.properties) for configuring database credentials.
I am trying to access this file from a class (myProject\src\samplePackage\sampleDBConnect.java). I have exported samplePackage.jar into *myProject\webContent\WEB-INF\lib*.
I have a Test.jsp page which calls a method in sampleDBConnect.java.
When i am trying to run this Test.jsp page, the current directory path shows C:\Documents and Settings\username. I have my project in some other drive(E:).
Can someone tell me how to access the properties file....
getClass().getResourceAsStream("db.properties");
This assumes your db.properties is in the same directory "samplePackage".
If you want to keep it in src directory or say resource directory then use
getClass().getClassLoader().getResourceAsStream("db.properties");
Since your java code belongs to the same web project you don't have to create a jar of the same project and place that in the WEB-INF/lib folder
move db.properties to myProject\src dir,
java code:
InputStream input = sampleDBConnect.class.getClassLoader().getResourceAsStream("db.properties");

Java applet error

I am doing a project on applets. I designed the applet using netbeans. After building the project in netbeans, I took the directory "classes" and a .html file from the "build" directory and moved it to another new directory. This .html file includes the applet. The .html file displays the applet correctly, when it is viewed from my desktop.
I uploaded the "classes" folder and the .html file to my free server (host4ufree.com) using FileZilla. If I try to view the webpage online, I get the following error instead of the applet getting displayed:
java.lang.ClassFormatError: Extra bytes at the end of class file
I am using JDk 1.6.0 update 18, and uploaded the file using FileZilla both ASCII and binary format manner. Yet, I am not able to solve the error problem. Does anybody know the solution to this? Is there something wrong in the manner in which I'm trying to add the applet to my webpage?
The question is quite unclear :S Anyway...
I uploaded the "classes" folder and the .html file to my free server
(host4ufree.com) using FileZilla.
If your applet contains more that one class I do not recommend upload the project classes folder itself but wrap your applet classes to jar file before delpoying it.
Report if that helped

Categories