JSP error: The requested resource is not available
I am new to this site and as a programmer I consider myself a beginner / intermediate. I am new to java and need to work with JSP for a university course. I want to know what is wrong with this code because I am getting this error:
the requested resource is not available.
Here is my code:
session.jsp
<html>
<body>
<form method = Post action = "receiveName.jsp">
please enter your name: <input type = "text" name = "myname" size = 20></br>
<input type = "submit"><input type = "clear">
</form>
</body>
</html>
receiveName.jsp
<jsp:useBean id="bean" class="mynames.Names" scope="session"/>
<jsp:setProperty name="bean" property="myNames" param="myname"/>
<% String name = bean.getMyNames();
session.setAttribute("user", name);
%>
<html>
<body>
<a href = "showname.jsp">move to next page</a>
</body>
</html>
showName.jsp
<html>
<body>
Hello <% = session.getAttribute("user")%>
</body>
</html>
Names.java
package mynames;
public class Names{
private String myNames;
public Names(){
}
public void setMyNames(String name){
myNames = name;
}
public String getMyNames(){
return myNames;
}
}
I don't understand how to implement the bean concept very well and if I only run the receiveName.jsp method the following report appears:
org.apache.jasper.JasperException: /EjemploProfesor/Class/receiveName.jsp (line: 1, column: 1) The value for the useBean class attribute mynames.Names is invalid.
Every input from you will be greatly appreciated. BTW, I don't use IDE, only Sublime Text 2 works in Ubuntu and as Apache Tomcat 8.0.21 server
source to share
You will need to change "
to "
throughout your code.
For example,
<form method = Post action = "receiveName.jsp">
needs to be changed to
<form method = Post action = "receiveName.jsp">
Similarly, change the below lines
session.setAttribute("user", name);
<a href = "showname.jsp">
Hello <% = session.getAttribute("user")%>
to
session.setAttribute("user", name);
<a href = "showname.jsp">
Hello <% = session.getAttribute("user")%>
respectively
source to share