Código PHP:
///////////////esta es la pagina principal//////////////////getname.html
<jsp:useBean id="user" class="bean.userdata" scope="session">
<jsp:setProperty name="user" property="*" />
<html>
<head>
<title></title>
<script >
function validar()
{
var camp=document.formulario.elements["campos[]"];
for (var i=0;i<camp.length;i++)
{
if (camp[i].value.length==0)
{
var bool=false;break;
}
var bool=true;continue;
}
return bool;
}
</script>
</head>
<body>
<form method=post action="savename.jsp" name="formulario" id="formulario" onSubmit="return validar();">
What´s your name?<input type=text name="campos[]" id="txt1" size=20 ><br>
What´s your email adress?<input type=text name="campos[]" id="txt2" size=20><br>
<p><input type=submit name=Aceptar value=enviar ></p>
</form>
</body>
</html>
Código PHP:
<%@ page import = "bean.userdata" %>
<jsp:useBean id="user" class="bean.userdata" scope="session"/>
<jsp:setProperty name="user" property="*" />
<HTML>
<BODY>
<A HREF="next.jsp">Continue</A>
</BODY>
</HTML>
Código PHP:
////////////////////////next.jsp/////////////////////////////////
<%@page import="bean.userdata" %>
<jsp:useBean id="user" class="bean.userdata" scope="session" />
<HTML>
<body>
your entered<br>
<%
bean.userdata meber=(bean.userdata) pageContext.getAttribute("user") ;
String [] member=meber.getcampos();
if(member!=null)
{
for (int i=0;i<member.length;i++)
{
out.println(member[i]+"<BR>");
}
}
else
{
out.println("ok");
}
%>
name: <br>
email:
</body>
</HTML>
Código PHP:
///////////////////////////////////este es el bean ///////////////////////////////
package bean;
public class userdata {
private String username;
private String email,cadenas;
private java.util.Vector <String> campos=new java.util.Vector <String> ();
public userdata() {
//campos=new java.util.Vector<String>();
}
public String getcampos(int which)
{
return (String) campos.elementAt(which);
}
public String[] getcampos()
{
// Convert the members vector into an array of strings.
String[] memberArray = new String[campos.size()];
campos.copyInto(memberArray);
return memberArray;
}
public void setcampos(String[] memberArray)
{
// If there are no members, just clear out the vector.
if (memberArray == null)
{
campos.setSize(0);
return;
}
// Copy the contents of the member array into the members vector.
campos.setSize(memberArray.length);
for (int i=0; i < memberArray.length; i++)
{
campos.setElementAt(memberArray[i], i);
}
}
}
org.apache.jasper.JasperException: Exception in JSP: /prime/next.jsp:14
11:
12:
13:
14: String [] member=meber.getcampos();
15:
16: if(member!=null)
17: {
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:373)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet .java:729)
causa raíz
java.lang.NullPointerException
org.apache.jsp.prime.next_jsp._jspService(next_jsp .java:64)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet .java:729)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet .java:729)
Y no he logrado imprimir los campos de texto .............agradezco su ayuda me pudieran dar alguna pista....gracias.