One needs to validate the data on the form before submitting to
the server.  Usually one uses javascript to perform this task.
Put the javascript into a file and include it in the page.

Once on the server the data should be validated again to prevent attacks
from
hackers.  That's were the Struts form comes in.  One can use the validate
method
to re-validate input.
The above is just to make sure we don't waste time going to the database or
any EJBs, etc.


Then there may be the validation of data against the business model or data.
This is where we apply the business logic and perform any database related
tasks.

Here are some good resources:
http://home.earthlink.net/~dwinterfeldt/
http://jakarta.apache.org/struts/userGuide/resources.html
http://www.husted.com/about/struts/


-----Original Message-----
From: Chuck Amadi [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 25, 2001 6:49 AM
To: [EMAIL PROTECTED]
Subject: Any suggestions Prob with validation be passing to db


When the Submit.jsp form is complete it is passed to the ProcessForm.jsp
(Inserted to db)
Thus i have created a UserInfoValid.jsp as below. I now that i should'nt
use script albeit i need something to demostrate my keep.

jsp:useBean id="planBean" scope="session" class="PlanBean" />

<jsp:setProperty name="planBean" property="statusMsg"/>


<%! boolean valid = true ;  %>

<%  if ((planBean.getFirstName()).equals("")) { valid = false ;
        planBean.setStatusMsg(planBean.getStatusMsg() + "Please enter
your First Name "); } %>

<%  if ((planBean.getLastName()).equals("")) { valid = false;
        planBean.setStatusMsg(planBean.getStatusMsg() + "Please enter
your Last Name ");  } %>

<%  if ((planBean.getAddress()).equals("")){valid = false;
        planBean.setStatusMsg(planBean.getStatusMsg() +"Please enter
your Address "); }  %>

<%  if ((planBean.getEmail().equals(""))){ valid = false;
        planBean.setStatusMsg(planBean.getStatusMsg() +"Please enter
your Email Address "); } %>

<%  if ((planBean.getObservation()).equals("")){ valid = false;
        planBean.setStatusMsg(planBean.getStatusMsg() +"Please enter
your Comments "); } %>--%>

<%  if (valid) { %>

            <jsp:forward page="ProcessForm.jsp" />

<%  } else { %>
            <jsp:forward page="Submit.jsp" />
<% } %>

_________________________________________________________
Thus recieve the following - Cheers Chuckie

Error: 500

Location: /bbnpwardens/UserInfoValid.jsp

Internal Servlet Error:

javax.servlet.ServletException
        at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:459)
        at
_0002fUserInfoValid_0002ejspUserInfoValid_jsp_23._jspService(_0002fUserInfoV
alid_0002ejspUserInfoValid_jsp_23.java:177)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.ja
va:130)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:282)
        at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
        at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
        at org.apache.tomcat.core.Handler.service(Handler.java:287)
        at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
        at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:213)
        at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
        at java.lang.Thread.run(Thread.java:484)

Root cause:

java.lang.NullPointerException
        at
_0002fUserInfoValid_0002ejspUserInfoValid_jsp_23._jspService(_0002fUserInfoV
alid_0002ejspUserInfoValid_jsp_23.java:121)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.ja
va:130)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:282)
        at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
        at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
        at org.apache.tomcat.core.Handler.service(Handler.java:287)
        at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
        at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:213)
        at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
        at java.lang.Thread.run(Thread.java:484)
--
The views expressed by the sender of this message don't
necessarily represent those of Brecon Beacons National Park
Authority. This message is intended for the addressee(s) only
and is sent in confidence; if you receive it in error, please can you
let us know (at [EMAIL PROTECTED]) and then destroy all copies.
Nid yw'r farn a fynegir gan anfonwr y neges hon o anghenraid yn
adlewyrchu barn Awdurdod Parc Cenedlaethol Bannau Brycheiniog.
Neges yw hon a fwriadwyd ar gyfer y derbynnydd/derbynyddion
yn unig ac fe'i hanfonir yn gyfrinachol; os ydych yn ei dderbyn
mewn camgymeriad, a fyddech gystal â rhoi gwybod i
ni (yn [EMAIL PROTECTED]) ac yna dilëwch bob copi.

Reply via email to