Applet Class Not Found Error - java

i have just started learning jsp, i came across running Applet from jsp, the code below doesn't seems to work.
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>InfoVisual</title>
</head>
<body>
<jsp:plugin type="applet" codebase="WEB-INF/classes" code="DemoApplet.class" width="400" height="400">
<jsp:fallback>
<p>Unable to load applet</p>
</jsp:fallback>
</jsp:plugin>
<input name="btnShow" value="Show" type="submit">
</body>
</html>
My eclipse project structure is like below
I don't know why i can't see the applet running.
Have i placed files in right folders???

Classes in WEB-INF/classes are only visible to server-side code such as servlets. Instead create a JAR file containing the compiled classes required to run the applet are place them in the same location as the JSP file. The plugin tag will then look like
<jsp:plugin type="applet" code="DemoApplet.class" archive="MyAppletJar.jar" width="400" height="400">
<jsp:fallback>
<p>Unable to load applet</p>
</jsp:fallback>
</jsp:plugin>

this code worked perfectly:
<applet code="DemoApplet.class" name="DemoApplet" archive="DemoApplet.jar" width=300 height=300>
</applet>
and here is my project structure:
Thanx for the help :))

Related

HTTP Status 500-/index.jsp "/struts-tags" not found

Hi Can anyone help me out to resolve the error mentioned above.
I used a index.jsp file
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World</title>
</head>
<body>
<h1>Hello World From Struts2</h1>
<form action="hello">
<label for="name">Please enter your name</label><br/>
<input type="text" name="name"/>
<input type="submit" value="Say Hello"/>
</form>
</body>
</html>
After writing all the classes and xml files,I have run the classes by tomcat server but got an error as follows
Can anyone help me out as I am new to Struts
The taglib is included in struts-core.jar, and the container will discover it automatically.
for some reason, a taglib configuration is needed within web.xml, extract the TLD file from the struts-core.jar META-INF folder, and add a taglib element to the web.xml.
<!-- ... -->
</welcome-file-list>
<taglib>
<taglib-uri>/s</taglib-uri>
<taglib-location>/WEB-INF/struts-tags.tld</taglib-location>
</taglib>
</web-app>
Try these:
Seems like you copied the libraries manually and directly into the folder WEB-INF/lib of the project and eclipse doesn't sense them, I suggest that you copy any necessary libraries into WEB-INF/lib only through eclipse. I had this issue previously and only a refresh of the project solved the problem.
add struts2-core.jar to the project
download it here.
Select Project and right click, Click on the properties, Click on
libraries tab, Click on 'Add Jars', Add relevant jar for you.

Page not found error for html file used in jsp project

I am learning Jsp and working on a basic Jsp project which is using a HTML file in it.
When I run the HTML file, it gives page not found error and while running the Jsp, it does not load the form and button in it.
Kindly help me out.
Below are my HTML and Jsp files:
Index.html
<html>
<head><title>New</title></head>
<body>
<form action="myFirstJsp.jsp">
<input type="text" name="uname">
<input type="submit" name="submit">
</form>
</body>
</html>
myFirstJsp.jsp
<%#page import="java.util.Calendar"%>
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My First JSP</title>
</head>
<body>
<%String name= request.getParameter("uname");
out.println("Welcome " +name);%>
</body>
</html>
First check if your server is up & your app is well deployed on it. Check the request url being fired from the browser.
Also
It's a good practice to use jstl tag to provide urls in your application. It computes the context path averting 404 page not found errors due to incorrect urls.
<form action="<c:url value="/myFirstJsp.jsp">
Add the jstl library in your jsp
<%#taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"/>

struts2 mysql conection error in eclipse

I am connecting to MySQL using JDBC to the JSP, but it shows error classNotFoundException in eclipse in struts JSP page.
validate.java:
package com.demo;
import java.sql.*;
public class LoginValidate {
public boolean validateLogin(){
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/inspioqj_appointment");
return true;
}
}
Same code using in same project jsp file its working what is problem i am not understanding.
index.jsp:
<%# page language="java" import="java.sql.*" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<p> There is home page.</p>
<hr/>
login|
logout|
profile
<%
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/inspioqj_appointment");
%>
</body>
</html>
I have included MySQL java connector on lib folder in eclipse struts project, but it is not working in action controller validate.java but it is working in index.jsp page.
What is problem? I could not understand.
Its a pretty simple ClassNotFoundException. Make sure that the mySQL jar is present in the class-path of the project as well. You can do this by right-clicking the project, configure class-path and from there you can add the particular jar

(Eclipse) The value for the useBean class attribute is invalid

I have been looking for ages now but none of the solutions google offered me helped for my situation.
I wrote a simple JSP-File and only tried to use the "useBean" statement (that's the line where the error occurs):
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%# page import="package1.TestBean" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="test" class="package1.TestBean" />
</body>
</html>
My JavaBean is an empty class but has an empty constructor without parameters:
package package1;
public class TestBean {
public TestBean() {
}
}
I created the class by right-clicking the project folder and then using New->Class.
So as I already said, the error occurs in the following line:
<jsp:useBean id="test" class="package1.TestBean" />
And the error message is (as already named in the title) "The value for the useBean class attribute package1.TestBean is invalid."
Please help me! :-(
Edit: A friend of mine tried the same, on his computer it works. Now he sent me his project folder, I imported it and it works, too!?!?!?
Solution found: There was a conflict between two Tomcat installations. See comments on Question for more detailed information.
stop Tomcat,go to Project-->Clean ->select the respective project->click clean. start Tomcat again

Package Beans does not Exist

I am a .NET developer dabbling into the JSP world. I loaded NetBeans 6.5.1 and get an error in this page:
<%#page import="java.io" %>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"w3.org/TR/html4/loose.dtd">;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
the error is:
"Package Beans does not Exist"
I should add that I created a new Java Web Application and then copy-and-pasted some code that called for the above import. then I get the error.
Help with this error would be great along with any tutorials or books.
Something is wrong with the classpath. Your configuration of the server, plus setup in the WAR file, should be checked against a working one.

Categories