Moin zusammen,
als Neueinsteiger in das Thema EJB eine Frage an die Spezies unter Euch... (Konnt auch in Google nichts dazu finden...)
Ich habe ein EJB Beispiel in Eclipse umgesetzt, in dem die Methode aus dem Remote Interface über JSP und ein Servlet aufgerufen wird:
JSP:
<%@ 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>Beispielhafte Enterprise Webanwendung</title>
</head>
<body>
<form action="${pageContext.request.contextPath}/sagHallo">
<input type="text" name="name" />
<input type="submit" value="Press me!" />
</form>
</body>
</html>
Das Servlet:
package servlets;
import java.io.IOException;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ejb_modul.RemoteBusinessInterface;
public class ejbServlet extends javax.servlet.http.HttpServlet implements
javax.servlet.Servlet {
static final long serialVersionUID = 1L;
@EJB
RemoteBusinessInterface remoteBusinessIntf;
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String name = request.getParameter("name");
if (name == null || name.length() == 0) {
name = "anonymous";
}
response.getWriter().write(remoteBusinessIntf.sayH ello(name));
}
}
Also...
über's doGet des Servlets wird die Methode "sayHello" des Remote aufgerufen. So weit so gut...
Meine Frage als Neuling nun: Ist das nicht umständlich ? Kann man das nicht direkt aus dem JSP aufrufen ?
Wenn ja, wie genau (kurzes Codebeispiel wenn möglich)
Danke und Gruss, lagloose
als Neueinsteiger in das Thema EJB eine Frage an die Spezies unter Euch... (Konnt auch in Google nichts dazu finden...)
Ich habe ein EJB Beispiel in Eclipse umgesetzt, in dem die Methode aus dem Remote Interface über JSP und ein Servlet aufgerufen wird:
JSP:
<%@ 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>Beispielhafte Enterprise Webanwendung</title>
</head>
<body>
<form action="${pageContext.request.contextPath}/sagHallo">
<input type="text" name="name" />
<input type="submit" value="Press me!" />
</form>
</body>
</html>
Das Servlet:
package servlets;
import java.io.IOException;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ejb_modul.RemoteBusinessInterface;
public class ejbServlet extends javax.servlet.http.HttpServlet implements
javax.servlet.Servlet {
static final long serialVersionUID = 1L;
@EJB
RemoteBusinessInterface remoteBusinessIntf;
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String name = request.getParameter("name");
if (name == null || name.length() == 0) {
name = "anonymous";
}
response.getWriter().write(remoteBusinessIntf.sayH ello(name));
}
}
Also...
über's doGet des Servlets wird die Methode "sayHello" des Remote aufgerufen. So weit so gut...
Meine Frage als Neuling nun: Ist das nicht umständlich ? Kann man das nicht direkt aus dem JSP aufrufen ?
Wenn ja, wie genau (kurzes Codebeispiel wenn möglich)
Danke und Gruss, lagloose
Comment