File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to implement following Code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to implement following Code" Watch "How to implement following Code" New topic
Author

How to implement following Code

thomas colding
Ranch Hand

Joined: Mar 23, 2007
Posts: 60
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

Joined: Jan 28, 2008
Posts: 5575

use Code tag when you post your code . also scriptlet in jsp is consider poor practice
thomas colding
Ranch Hand

Joined: Mar 23, 2007
Posts: 60
Any suuggestion how to Validate a user input,

Sorry I Newbie developing JSP's
azhar jodatti
Greenhorn

Joined: Oct 18, 2009
Posts: 12
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"


..FEEL IT..
thomas colding
Ranch Hand

Joined: Mar 23, 2007
Posts: 60
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

Joined: Mar 15, 2009
Posts: 452



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


SCJP 5.0 SCWCD 5.0
thomas colding
Ranch Hand

Joined: Mar 23, 2007
Posts: 60
So the answer is to use Beans with Custom tags to validate the form
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452

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

Joined: Jan 10, 2002
Posts: 60041
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
thomas colding
Ranch Hand

Joined: Mar 23, 2007
Posts: 60
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to implement following Code
 
Similar Threads
getting JSP to recognize my bean!!!
Attribute has no value
Object reference not working with Bean method
Getting the name of the requesting page
How to achive server validation of a dynamic form