• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to implement following Code

 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to implement a JSP page without succes, The JSP page is downloaded from the net.

The Code is as following, can anybody translate how do I Instanciate the object to acces the method 'Validate'
The method 'validate' is inside a package name FormBean


%>
<jsp:useBean id="formHandler" class="test.FormBean" scope="request">
<jsp:setProperty name="formHandler" property="*"/>
</jsp:useBean>
<%
if (formHandler.validate()) {
%>
<jsp:forward page="success.jsp"/>
<%
} else {
%>
<jsp:forward page="retry.jsp"/>
<%
}
%>






 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use Code tag when you post your code . also scriptlet in jsp is consider poor practice
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suuggestion how to Validate a user input,

Sorry I Newbie developing JSP's
 
azhar jodatti
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it the method is inside the package name formfield then your class option on useBean should be full path of the class....
like class="package name.classname"

 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Any suggestion which approach to use to validate User input.

If not scriptlet in jsp then what else??, any suggestion is appreciated
As I mentioned I am newbie in JSP and Portlets
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


first thing i have corrected the code <jsp.xxx> are called standard actions and can't be written inside <% %>

jsp:usebean here is creating an instance of FormBean and passing the request parameters to its fields. it won't work if the parameters and the bean class don't follow the bean name convention.

if you want to execute the validate method the code written above will work but it is using scripting which is not a good practice.

you can better create a custom tag to invoke it .

avi sinha
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the answer is to use Beans with Custom tags to validate the form
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thomas colding wrote:So the answer is to use Beans with Custom tags to validate the form


custom tag is alone sufficient to handle all the work if you can implement it efficiently.

Have a look ( custom tag tutorial)

avi sinha
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are new to JSP then you should be learning the modern accepted practices and not following old, discredited ways of doing things.

Performing processing in a JSP is a horrible way to structure your application. Using scriptlets in a JSP is an outdated and scorned practice.

Perhaps this article can start to shed some light on modern web application constructs.
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:If you are new to JSP then you should be learning the modern accepted practices and not following old, discredited ways of doing things.

Performing processing in a JSP is a horrible way to structure your application. Using scriptlets in a JSP is an outdated and scorned practice.

Perhaps this article can start to shed some light on modern web application constructs.


Thanks it was reason since I asked for suggestion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic