I know this topic has come up numerous times however after going through as many questions as i could find I still haven't resolves my issue.
To begin I'm just starting out with Java Web and to learn I am using the NetBeans tutorial. I'm using NetBeans 8.2 IDE and Tomcat 8 for server. After following all the steps and running it I get the following Error:
For the code:
NameHandler.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mypackage.hello;
/**
*
* @author johnl_000
*/
public class NameHandler {
private String name;
public NameHandler(){
name = null;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
}
index.jsp
<%--
Document : index
Created on : 26-Nov-2016, 10:41:06
Author : johnl_000
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Entry Form</h1>
<form name="Name Input Form" action="response.jsp">
Enter your name:
<input type="text" name="Name" />
<input type="submit" value="OK" />
</form>
</body>
</html>
response.jsp
<%--
Document : response
Created on : 26-Nov-2016, 10:59:30
Author : johnl_000
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:useBean id="mybean" scope="session" class="org.mypackage.hello.NameHandler" />
<jsp:setProperty name="mybean" property="name" />
<h1>Hello, <jsp:getProperty name="mybean" property="name" />!</h1>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire