Why do we declare the variables private in a bean

Hi,
when we create a bean in the MVC architecture why do we declare the variables private. Also when do we use the access specifier private.
Regards,
Prashant

pksingh79 wrote:
Hi ^^,
thanks for replying.I had a discussion with one of my trainers and he was of the opinion that the variables should generally be declared private. In this way we prevent classes from accessing and setting illegal values to those variables.
Say for instance we have the class person as follows:
public class Person
int age;
setAge(int age)
if (age < 0)
return null
Person p = new Person() ;
p.age = -2;
//this would be perfectly legal
//where as if we declare the variable as private as follows:
public class Person
private int age;
setAge(int age)
if (age < 0)
return null
Person p = new Person() ;
// P.age = -2;   this would be illegal as age is private and would have to be accessed by the method defined above.
p.setAge(-2);
//the cbove line would retun null values.
public class Person {
    private int age;
    public void setAge(int age) {
        if (age < 0) {
            throw new IllegalArgumentException("...");
        this.age = age;
}

Similar Messages

  • HOW TO ACHIEVE THE Variable Substitution THROUGH MODULE BEAN

    Hi All,
    i know the variable substitution for getting the one the value from the payload.
    how can we achieve same thing through using the module been. below screen for your reference.
    help us module bean for variable substitution.
    Regards,
    Kesava

    Hi,
    refer the below link..
    http://scn.sap.com/people/jin.shin/blog/2007/04/27/sap-netweaver-xi-variable-substitution-with-adapter-specific-message-attributes-via-dynamicconfigurationbean
    Regards
    srinivas

  • Why should i declare a variable serialVersionUID?

    hello all,
    the following code giving warning saying that
    The serializable class newFrame does not declare a static final
    serialVersionUID field of type long.
    why should i need to declare a static final
    serialVersionUID variable? is their any resason
    public class newFrame extends JFrame{
         public ContentPaneTest() {
             super("Content pane");
             getContentpane().add(new JLabel("hello all"););
             setVisible(true);
             pack();
             setDefaultCloseOperation(EXIT_ON_CLOSE);
         public static void main(String args[]){
              new newFrame();
    }thanks
    daya

    two options:
    1) You could explicitly specify a serialVersionUID to remove the warnings.
    2) If you just want to remove those specific warnings, you could do so by changing the compiler settings of your IDE (for Eclipse, "Potential programming problems" / "Serializable class without serialVersionUID").
    serialVersionUID is used during deserialization to verify that the sender and receiver of a serialized object have compatible corresponding classes (for that object).
    If you don't care about serialization, 2) would be your choice.

  • ODI - to declare the variable for the path in Modules & Interface

    Hi,
    I have different server names like Development, Test & Production. I have installed ODI client in my local machine.
    1. For creating *10 modules*, i have the flat files in Development server. For now i can hard code the path by \\Development\ODI_FileStore....
    2. In the Interface i am using the hard coded paths for the logs.
    Is there any possibility to create a variable for the shared folder and use that variable (like environment variables ...) instaed of using the hardcoded path. If so, can you explain tme how i can create.
    Your advise will help me a lot and will be appreciated.
    Thanks & Regards
    Dhamu

    Dhamu,
    I think when you say modules, you mean models.
    To use multiple files in the same interface, you can use ODI variables.
    Read this link for more information : http://odiexperts.com/multiple-files-single-interface

  • Declaring a variable in a function: either the function or the eventListener I'm using doesn't work

    Can anyone help me with this?
    I have a set of Cue Points in an FLV I'm playing. It's an interactive quiz, so the idea is that flash will change a variable, theAnswer, to a different letter depending on which question it is. The answer to question 1 is B, question 2 is D, etc.
    Either the cue point event listener isn't working, or else it is working and Flash isn't declaring the variables. Can someone help?
    The error message I get is:
    1120: Access of undefined property theAnswer.
    I literally can't find a single problem with my code. I have an almost identical Event Listener further down which works.
    var theAnswer;
    vid.addEventListener(MetadataEvent.CUE_POINT, cueAnswers);
    function cueAnswers(e:MetadataEvent):void{
    var cuePointNames = e.info.name;
    if (cuePointNames =="start")
    theAnswer = "C";
    else if (cuePointNames =="q2")
    theAnswer = "A";
    else if (cuePointNames =="q3")
    theAnswer = "C";
    else if (cuePointNames =="q4")
    theAnswer = "A";
    else if (cuePointNames =="q5")
    theAnswer = "D";
    else if (cuePointNames =="q6")
    theAnswer = "C";
    else if (cuePointNames =="q7")
    theAnswer = "A";
    else if (cuePointNames =="q8")
    theAnswer = "D";
    else if (cuePointNames =="q9")
    theAnswer ="B"
    else if (cuePointNames =="q10")
    theAnswer ="B";
    The function is called by this later:
    function nkAinfo(e:MouseEvent):void {
    if (theAnswer=="C")
    trace("You clicked right");
    else
    trace("You clicked wrong");
    What's going on? Is the function not being called or are my variable declarations wrong?

    Probably not the answer to your question, but it could help anyways....
    First there is another command that, to me at least, is much easier to read that a bunch of nested if/if elses. And that is the switch.
    switch (e.info.name){
    case "start":
    theAnswer="C";
    break;
    case "q2":
    theAnswer="A"
    break;
    //and so on
    To me that is easier to maintain and read. But I don't think that is really what you need here. So just file that one away for the future.
    In this case, what I think you need is an array.
    var currentAnswer:String;
    var correctAnswers:Array=new Array();
    correctAnswers["start"]="C"
    correctAnswers["q2"]="A"
    // and so on.
    Then your cuepoint handler function becomes something like this:
    function cueAnswers(e:MetadataEvent):void{
         currentAnswer=correctAnswers[e.info.name];
    And I'm a little confused by your mouse click handler. It would seem to suggest that the answer is always "C"? But I"m guessing that it is supposed to compare what the user clicked on to what the cuePoint has told it is the correct answer? Well if that is the case then it would probably look something like:
    function nkAinfo(e:MouseEvent):void {
    if(e.currentTarget.clickedProperty==currentAnswer){
         trace("Correct");
    } else {
         trace("Incorrect");
    With the way you are currently doing this I'm guessing that you have a bunch of repeated functions for each time there is a mouse click and that your code is a lot more complicated that it needs to be. And that somewhere hiding in all those lines there is an error that would be simple to fix if you could see it.
    What the error is telling you is that somewhere your are trying to assign or retrieve theAnswer and it hasn't been defined yet.

  • Why I should declare a final object!

    import java.util.*;
    public class Problem {
    public static void main(String[] args) {
    Timer timer = new Timer();
    timer.schedule(new TimerTask() {
    public void run() {
    System.out.println("Exiting.");
    timer.cancel();
    5000);
    System.out.println("In 5 seconds this
    application will exit. ");
    When I complie the program there is one error as follow:
    Problem.java:11: local variable timer is accessed from within inner class; needs
    to be declared final
    timer.cancel();
    1 error
    I don't kown why I must declare the timer as "final"!
    Help me!

    What you have is an anonymous inner class. For this class to be able to access local variables in the containing class they must be final. When the compiler compiles the code it will create the inner class with a reference to the variable. If you were able to change the variable the inner class would lose the reference.

  • Declaring the var in the constructer

    How can someone do this without declaring the photos var before the constructer as a field?
    package org.robotlegs.demos.imagegallery.models.vo
        import mx.collections.ArrayCollection;
        [Bindable]
        public class Gallery
            public var photos:ArrayCollection = new ArrayCollection()

    Hi Nikos,
    By your saying that the declaring fields here out side the constructor..Do you really mean it...why because in your code you doesn't seem to have a
    constructor and you are actually trying to declare the variable outside the class infact but not outside the constructor..
    So you are trying to do the follwing which is wrong..:
    //Here you are declaring the variable outside the class indeed which is wrong..
    package org.robotlegs.demos.imagegallery.models.vo
         import mx.collections.ArrayCollection;
         public var photos:ArrayCollection = new ArrayCollection()
         [Bindable]
         public class Gallery
    Infact you should do this ....
    package org.robotlegs.demos.imagegallery.models.vo
         import mx.collections.ArrayCollection;
         [Bindable]
         public class Gallery
             public var photos:ArrayCollection = new ArrayCollection()
             //Your Constructor
             public function Gallery()
    Hope you understood my point....
    Thanks,
    Bhasker Chari

  • Confusion with the the variables

    I have confusion regarding the use of variables in JSP. When i declare the variable with a <set> tag and then try to use it with scriplet tag,,<% .....%>,,it dosn't work. why so?
    <code>
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
    <HTML>
    <HEAD>
    <TITLE>EDIT YOUR PROFILE</TITLE>
    </HEAD>
    <BODY BGCOLOR="BLACK" TEXT="WHITE">
    <H1 ALIGN="CENTER"><FONT COLOR="YELLOW"><BLINK>REGISTER</BLINK></FONT></H1>
    <H2 ALIGN="CENTER">PLEASE FILL IN YOUR DETAILS</H2>
    <PRE>
    </PRE>
    <FORM METHOD="POST" ACTION="enter.jsp">
    DELIVERY CHARGES:<td><INPUT TYPE="TEXT" NAME="user_charge1" SIZE="40">
    <c:set var="n" value="${param.size}" scope="session"/>
    <table>
    <%
    for(int i=0;i<n;i++){%>
    <tr><td>PRODUCT:<td><INPUT TYPE="TEXT" NAME="user_pdt1_1" SIZE="40"><td>PRICE1:<td><INPUT TYPE="TEXT" NAME="user_pr1_1" SIZE="10"></tr>
    <%}%>
    </table>
    <BR>
    <PRE>
    </PRE>
    <P ALIGN="CENTER"><FONT COLOR="YELLOW">THANX FOR YOUR SUPPORT!!</FONT></P>
    <P ALIGN="CENTER"><INPUT TYPE="SUBMIT" VALUE="SUBMIT">
    <INPUT TYPE="RESET" VALUE="RESET">
    </P>
    </FORM>
    </BODY>
    </code>
    this is the error generated....
    <error>
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 25 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:11: illegal start of type
    for(int i=0;i<n;i++){
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:119: <identifier> expected
    org.apache.taglibs.standard.tag.rt.core.SetTag jspxth_c_set_0 = (org.apache.taglibs.standard.tag.rt.core.SetTag) jspxtagPool_c_set_var_value_scope_nobody.get(org.apache.taglibs.standard.tag.rt.core.SetTag.class);
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:119: <identifier> expected
    org.apache.taglibs.standard.tag.rt.core.SetTag jspxth_c_set_0 = (org.apache.taglibs.standard.tag.rt.core.SetTag) jspxtagPool_c_set_var_value_scope_nobody.get(org.apache.taglibs.standard.tag.rt.core.SetTag.class);
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:119: '{' expected
    org.apache.taglibs.standard.tag.rt.core.SetTag jspxth_c_set_0 = (org.apache.taglibs.standard.tag.rt.core.SetTag) jspxtagPool_c_set_var_value_scope_nobody.get(org.apache.taglibs.standard.tag.rt.core.SetTag.class);
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:120: <identifier> expected
    jspxth_c_set_0.setPageContext(_jspx_page_context);
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:121: <identifier> expected
    jspxth_c_set_0.setParent(null);
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:122: <identifier> expected
    jspxth_c_set_0.setVar("n");
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:123: <identifier> expected
    jspxth_c_set_0.setValue((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.size}", java.lang.Object.class, (PageContext)_jspx_page_context, null, false));
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:123: ';' expected
    jspxth_c_set_0.setValue((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.size}", java.lang.Object.class, (PageContext)_jspx_page_context, null, false));
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:123: <identifier> expected
    jspxth_c_set_0.setValue((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.size}", java.lang.Object.class, (PageContext)_jspx_page_context, null, false));
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:123: '{' expected
    jspxth_c_set_0.setValue((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.size}", java.lang.Object.class, (PageContext)_jspx_page_context, null, false));
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:124: <identifier> expected
    jspxth_c_set_0.setScope("session");
    ^
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:126: illegal start of type
    if (_jspx_th_c_set_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
    ^
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:130: <identifier> expected
    jspxtagPool_c_set_var_value_scope_nobody.reuse(_jspx_th_c_set_0);
    ^
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:131: illegal start of type
    return false;
    ^
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:131: <identifier> expected
    return false;
    ^
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:134: '}' expected
    ^
    17 errors
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 25 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:11: illegal start of type
    for(int i=0;i<n;i++){
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:119: <identifier> expected
    org.apache.taglibs.standard.tag.rt.core.SetTag jspxth_c_set_0 = (org.apache.taglibs.standard.tag.rt.core.SetTag) jspxtagPool_c_set_var_value_scope_nobody.get(org.apache.taglibs.standard.tag.rt.core.SetTag.class);
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:119: <identifier> expected
    org.apache.taglibs.standard.tag.rt.core.SetTag jspxth_c_set_0 = (org.apache.taglibs.standard.tag.rt.core.SetTag) jspxtagPool_c_set_var_value_scope_nobody.get(org.apache.taglibs.standard.tag.rt.core.SetTag.class);
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:119: '{' expected
    org.apache.taglibs.standard.tag.rt.core.SetTag jspxth_c_set_0 = (org.apache.taglibs.standard.tag.rt.core.SetTag) jspxtagPool_c_set_var_value_scope_nobody.get(org.apache.taglibs.standard.tag.rt.core.SetTag.class);
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:120: <identifier> expected
    jspxth_c_set_0.setPageContext(_jspx_page_context);
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:121: <identifier> expected
    jspxth_c_set_0.setParent(null);
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:122: <identifier> expected
    jspxth_c_set_0.setVar("n");
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:123: <identifier> expected
    jspxth_c_set_0.setValue((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.size}", java.lang.Object.class, (PageContext)_jspx_page_context, null, false));
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:123: ';' expected
    jspxth_c_set_0.setValue((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.size}", java.lang.Object.class, (PageContext)_jspx_page_context, null, false));
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:123: <identifier> expected
    jspxth_c_set_0.setValue((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.size}", java.lang.Object.class, (PageContext)_jspx_page_context, null, false));
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:123: '{' expected
    jspxth_c_set_0.setValue((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.size}", java.lang.Object.class, (PageContext)_jspx_page_context, null, false));
    ^
    An error occurred at line: 23 in the jsp file: /multiple_entry.jsp
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:124: <identifier> expected
    jspxth_c_set_0.setScope("session");
    ^
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:126: illegal start of type
    if (_jspx_th_c_set_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
    ^
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:130: <identifier> expected
    jspxtagPool_c_set_var_value_scope_nobody.reuse(_jspx_th_c_set_0);
    ^
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:131: illegal start of type
    return false;
    ^
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:131: <identifier> expected
    return false;
    ^
    Generated servlet error:
    C:\Users\raghu\.netbeans\5.5\apache-tomcat-5.5.17_base\work\Catalina\localhost\temp2\org\apache\jsp\multiple_005fentry_jsp.java:134: '}' expected
    ^
    17 errors
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.AntCompiler.generateClass(AntCompiler.java:249)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
    Apache Tomcat/5.5.17
    </error>
    please provide the solution..!!...

    hShekhar wrote:
    1. scriptlet <%for loop %> good with countsCan also be done with c:forEach. There is absolutely no need to prefer scriptlets above the c:forEach.
    2.c tag <c:foreach></c:foreach> good with arrays nd arraylistsAlso with counts and collections of DTO's.
    3 logic iterate tag <logic:iterate></logic:iterate> good with arraylist with specific data (like VOs)This is not a JSP/JSTL tag. It is an Apache Struts tag. That same way I can also suggest another tags like h:dataTable, t:dataList, ui:repeat, etcetera. And the c:forEach can just also handle collections of DTO's.
    Summarized: your answer makes not much sense.

  • How to use the variables used in the message mapping

    Hi ,
    In the message mapping we can declare variables in the JAVA section , these variables could be used across the mapping .
    I have tried using it but I am unable to retrieve the values assigned to the variables in one UDF into the another UDF .
    Please guide me how to use the variables declared in the JAVA section in the message mapping .
    Thanks
    Anita Yadav

    Anita,
    I have worked on the Global variables and i found no issues. Make sure that the variable is declared in the Declaration Section and then initlaized in the Initialization section.
    If you declare a variable in the Declaration Section ,
    int i;
    then in any udf you can use if directly. No need to re declare  the variable in the UDF. If you do this, then it becomes a local variable.
    Regards,
    Bhavesh

  • How to use the variable value "ALL"

    Hello all,
    I'm trying to use the value "all" for a selection variable in a Web Interface so that to have no restrictions for that specific variable and that all the rows are shown on the interface.
    Unfortunately it does not seem to be working because when I select the value "all" the system seems to go back to the latest rows saved under a specific value for that variable and does not show all the rows saved under any variable's value.
    Anyone knows how to make this work? One option is to remove the variable from the web interface altogether, but that's my last option.
    Thanks in advance.
    Best regards,
    Francesco

    Hi Francesco,
    why is leaving out the variable your last option? If you want to select "all" then you don´t need a variable.
    Cornelia

  • Would like to declare a variable Public/Global in an IF statement

    Is there way to declare a variable as Public in an IF statement. My goal is to declare the variable as global (since this variable is used somewhere in the code and should not get initialized when there is loop back to the top of the code, hence using IF statement to control the initialization) based on the IF condition and then use it elsewhere in the code.
    I have it like this
    if (!sei_second_jsp.equals("1"))
    public int[] mecitem;
    public String[] sei_mfg_prod_cat;
    public String[] sei_part_number;
    public String[] sei_descrip;
    public String[] sei_price;
    public int[] sei_onhand;
    public int[] sei_demand;
    mecitem = new int[20000];
    sei_mfg_prod_cat = new String[20000];
    sei_part_number = new String[20000];
    sei_descrip = new String[20000];
    sei_price = new String[20000];
    sei_onhand = new int[20000];
    sei_demand = new int[20000];
    for (int i=0; i<=19999; i++)
    mecitem[i] = 0;
    sei_mfg_prod_cat[i] = " ";
    sei_part_number[i] = " ";
    sei_descrip[i] = " ";
    sei_price[i] = " ";
    sei_onhand[i] = 0;
    sei_demand[i] = 0;
    Your guess is right, I am using this code in JSP - since this is a Java related question, thought of posting it in JAVA forum.
    When I use the above code, I get the following error
    1809 }' expected. { 
    1811 Statement expected. public int[] mecitem;
    1827 Identifier expected. mecitem = new int[20000];
    1827 Can't specify array dimension in a declaration. mecitem = new int[20000];
    1827 Identifier expected. mecitem = new int[20000];
    1837 Can't specify array dimension in a declaration. sei_onhand = new int[20000];
    1837 Identifier expected. sei_onhand = new int[20000];
    1839 Can't specify array dimension in a declaration. sei_demand = new int[20000];
    1839 Identifier expected. sei_demand = new int[20000];
    3117 Class or interface declaration expected. }

    Please note the above code in the JSP is submitting to itself and I donot want it to get initialized if the IF statement is not successful..
    thnks a lot for your time.. !!!

  • Declare @p1 variable error when creating multiple search form to show database info

    Hi, all help is incredibly appreciated,
    i have been trying to make a multiple filtered search form for a database in asp / vbscript. I want to be able to select from THIS database table, all info on the rows which id is BETWEEN x and x AND date is BETWEEN x and x AND securitynumber is BETWEEN x and x
    what would be the best way to do this?
    this is what ive got so far, which gives me the error:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare the variable '@P1'.
    <%
    Dim rsBundleR__p_selectedDB
    rsBundleR__p_selectedDB = request.form("selectedDataBase")
    If (request.form("selectedDataBase") <> "") Then
      rsBundleR__p_selectedDB = request.form("selectedDataBase")
    End If
    %>
    <%
    Dim rsBundleR__p_idFrom
    rsBundleR__p_idFrom = request.form("bundleIdFrom")
    If (request.form("bundleIdFrom")  <> "") Then
      rsBundleR__p_idFrom = request.form("bundleIdFrom")
    End If
    %>
    <%
    Dim rsBundleR__p_idTo
    rsBundleR__p_idTo = request.form("bundleIdTo")
    If (request.form("bundleIdTo") <> "") Then
      rsBundleR__p_idTo = request.form("bundleIdTo")
    End If
    %>
    <%
    Dim rsBundleR__p_dateFrom
    rsBundleR__p_dateFrom = request.form("fromDate")
    If (request.form("fromDate") <> "") Then
      rsBundleR__p_dateFrom = request.form("fromDate")
    End If
    %>
    <%
    Dim rsBundleR__p_dateTo
    rsBundleR__p_dateTo = request.form("toDate")
    If (request.form("toDate") <> "") Then
      rsBundleR__p_dateTo = request.form("toDate")
    End If
    %>
    <%
    Dim rsBundleR__p_ssFrom
    rsBundleR__p_ssFrom = request.form("fromSS")
    If (request.form("fromSS") <> "") Then
      rsBundleR__p_ssFrom = request.form("fromSS")
    End If
    %>
    <%
    Dim rsBundleR__p_ssTo
    rsBundleR__p_ssTo = request.form("toSS")
    If (request.form("toSS") <> "") Then
      rsBundleR__p_ssTo = request.form("toSS")
    End If
    %>
    <%
    Dim rsBundleR
    Dim rsBundleR_cmd
    Dim rsBundleR_numRows
    Set rsBundleR_cmd = Server.CreateObject ("ADODB.Command")
    rsBundleR_cmd.ActiveConnection = MM_PHPSQL_STRING
    rsBundleR_cmd.CommandText = "SELECT * FROM ? WHERE id BETWEEN ? AND ?  AND fecha_solicitado BETWEEN ? AND ?  AND seguro_social BETWEEN ? AND ? ORDER BY id ASC"
    rsBundleR_cmd.Prepared = true
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param1", 200, 1, 255, rsBundleR__p_selectedDB) ' adVarChar
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param2", 5, 1, -1, rsBundleR__p_idFrom) ' adDouble
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param3", 5, 1, -1, rsBundleR__p_idTo) ' adDouble
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param4", 135, 1, -1, rsBundleR__p_dateFrom) ' adDBTimeStamp
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param5", 135, 1, -1, rsBundleR__p_dateTo) ' adDBTimeStamp
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param6", 200, 1, 255, rsBundleR__p_ssFrom) ' adVarChar
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param7", 200, 1, 255, rsBundleR__p_ssTo) ' adVarChar
    Set rsBundleR = rsBundleR_cmd.Execute
    rsBundleR_numRows = 0
    %>
    someone, please help, this is very important!

    allright i think thats what i did here:
      <% While ((Repeat1__numRows <> 0) AND (NOT rsBundleR.EOF)) %>
    <table align="center" border="1">
              <tr>
                <td align="left" width="50%">id</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("id").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">seguro_social</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("seguro_social").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">numero_estudiante</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("numero_estudiante").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">nombre</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("nombre").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">apellido</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("apellido").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">telefono</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("telefono").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">celular</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("celular").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">email_pupr</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("email_pupr").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">ciudad</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">estado</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">zona_postal</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_fisica</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_fisica").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_fisica_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_fisica_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">email_personal</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("email_personal").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">ciudad_fisica</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad_fisica").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">estado_fisica</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado_fisica").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">zona_postal_fisica</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal_fisica").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">tipo_estudiante</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("tipo_estudiante").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">termino_prestamo</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("termino_prestamo").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">nombre_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("nombre_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">apellido_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("apellido_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">telefono_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("telefono_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal_1_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_1_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal_2_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_2_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">ciudad_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">estado_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">zona_postal_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">nombre_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("nombre_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">apllido_refencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("apllido_refencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">telefono_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("telefono_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal_1_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_1_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal_2_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_2_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">ciudad_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">estado_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">zona_postal_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">tipo_de_prestamo</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("tipo_de_prestamo").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">cantidad_prestamo</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("cantidad_prestamo").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">subsidiado</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("subsidiado").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">no_subsidiado</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("no_subsidiado").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">autorizo_pupr</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("autorizo_pupr").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">fecha_solicitado</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("fecha_solicitado").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">estatus</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("estatus").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">revisado_por</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("revisado_por").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">nota_personal</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("nota_personal").Value)%></td>
              </tr>
            </table>
      <br /><br />
        <%
      Repeat1__index=Repeat1__index+1
      Repeat1__numRows=Repeat1__numRows-1
      rsBundleR.MoveNext()
    Wend
    %>
    , no error is given BUT still, no information is showing.
    However, i dont see the "." either :/
    I made it create a table for each record,
    is it the way i called the information?
    or is the query not finding anything?
    ( there is information in the database )

  • Why we are making a variable as final in method inner class ?

    Why we are making the variable as final (method inner class) while we are accessing the method variable in inner class ?
    regards,
    namanc

    As far as I can tell, the only reason is to protect the programmer: when the inner class instance is constructed, it is given the then-current value of the variable. If the variable (or method parameter) later changes, the value held by the inner class would not. By making the variable final, the programmer doesn't have to worry about them staying in sync.
    Here's some code to ponder:
    public class InnerExample
        void printMe( final int x )
            Runnable runMe = new Runnable()
                public void run()
                    System.out.println(x);
            (new Thread(runMe)).start();
    }When compiled with the Sun JDK 1.4.2, you get this bytecode:
    void printMe(int);
      Code:
       0:   new     #2; //class InnerExample$1
       3:   dup
       4:   aload_0
       5:   iload_1
       6:   invokespecial   #3; //Method InnerExample$1."<init>":(LInnerExample;I)V
       9:   astore_2
       10:  new     #4; //class Thread
       13:  dup
       14:  aload_2
       15:  invokespecial   #5; //Method java/lang/Thread."<init>":(Ljava/lang/Runnable;)V
       18:  invokevirtual   #6; //Method java/lang/Thread.start:()V
       21:  returnAt line (byte) 5, it loads the passed value onto the stack; at line 6, it invokes the inner class constructor (which is created by the compiler). Nothing in this sequence of code would prevent use of a non-final variable.

  • Variable don't recognized. Not found in the variable collection.

    Hi guys, I am literally getting crazy with an error that I can understand the reason. I even wrote an article on this kind of process and now I am stuck on it.
    Process: Reading a select count from a query and passing the variable to a send email task. Easy but..
    Why?! Why this error? The variable is in the variable collection!!
    Any suggestion? Thanks (I'm getting crazy on it)

    You should use it like this
    @wrong > 0
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Why can't i edit the variable declaration in Netbeans GUI Applications?

    When i drag and drop jbutton,jlabel and other tools from toolbox on the jform the code is
    automatically generated by the Netbeans.
    At bottom the variable declaration for the jbutton and for the other tools is automatically
    generated.
    The part of that declaration is shaded as grey.
    Is it possible to edit those variables from Netbeans?

    Yup, as Chuck states, it is possible to edit that region of code, since the file is nothing more than a text file, but doing so "breaks" the code so that you cannot modify the GUI content in NetBeans WYSIWYG form editor. Please note, that there are ways of changing the characteristics of those variables without editing them directly. You should look into how to change properties of your GUI with NetBeans. The online tutorials can show you how.

Maybe you are looking for

  • Need Help to locate a file on a FTP server using MediaLocator class

    Hi Friends, This is Venkat. Iam currently working on a Multimedia J2EE web project. Iam working on a requirement to show Thumbnail view for uploaded media. For this i have downloaded a standalone code from the following site. http://www.exactfutures.

  • How to download a .pdf file from a JavaMail application?

    hi to all, iam unable to download a .pdf file from a mailserver using my javamail application.i have downloaded all kind of files except .pdf. my code snipnet: public static void dumpPart(Part p) throws Exception { //     if (p instanceof Message)   

  • PO Number not showing in RE Document Type

    Hi, When i run the transaction FBL3N with a G/L Account (205030 - MODVAT CLEARING), it shows the Purchase Document Number in some line items, but not in all. When I check, it shows that in Document Type SA, Purchase Document No. is showing but in RE

  • Bapi's

    hi, how to upload the master data from flat file to sap system using bapi's.please give me step by step.

  • Where is  mobile stock management customizing guide ?

    Hello For CRM 2007 mobile stock management in Mobile service. Netweaver 7.1 mobile is mandatory. However, I could not find the IMG guide for this area. Such as connectivity setup between that and CRM or backend ECC. Has anyone done that part? Thanks