Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Jsp Html question

Options
  • 28-03-2006 3:56pm
    #1
    Closed Accounts Posts: 18


    ok guys i have been hounded by this prob for 2 hours now, so here it is.
    i have a html page anda jsp page, i have a load of info on this jsp page i just want to set the textfields in my html page to the variables in the jsp page, how do i do this?


Comments

  • Registered Users Posts: 27,163 ✭✭✭✭GreeBo


    piemaster wrote:
    ok guys i have been hounded by this prob for 2 hours now, so here it is.
    i have a html page anda jsp page, i have a load of info on this jsp page i just want to set the textfields in my html page to the variables in the jsp page, how do i do this?
    Why do you have two pages?
    Use the JSP for display...


  • Closed Accounts Posts: 18 piemaster


    well is it not better programming, and more secure to do it with a html page that calls a do-fill.jsp then just fills the html rather than have a jsp page with all my code hard coded on it?


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    "set the textfields in my html page to the variables in the jsp page"

    do you mean

    <input type="text" value="jsp-variable"/> or something to that effect?


  • Registered Users Posts: 6,420 ✭✭✭Doodee


    not able to use get'ers and set'ers?

    formname.filedname.value?

    I'm not sure, i just awoke from a nap.


  • Closed Accounts Posts: 18 piemaster


    my problem is this.

    i have all the get methods called in the JSP file and assigned to strings.I want to assign those strings to the textfields in the HTML file.

    any suggestions?


  • Advertisement
  • Registered Users Posts: 1,275 ✭✭✭bpmurray


    You clearly are missing the basic, fundamental purpose of a JSP. You're trying to use it as a session bean instead of a PAGE (yes, that's what the "P" stands for). A JSP has basically two identities: it is a bunch of HTML (yes your HTML page) with potentially Java code embedded. In fact, I always stress that this is best done using tags rather than pure Java, making your page close to 100% markup.

    So, take your HTML file and merge it into your JSP. You shouldn't have two files - that is an error. You do it like:
    <input type="text" value="<%=bean.getProperty()%>">
    

    In other words, you don't need to assign the values to page variables, but rather directly to the fields.


  • Closed Accounts Posts: 18 piemaster


    ok i have tried the following code

    <jsp:useBean id="myForm1" class="pubs.TitlesDAO" scope="session" />
    <jsp:setProperty name="myForm1" property="*"/>

    <input name="user_name" type="text" value="<%=myForm1.getuser_name()%>"> it showing nothing and in the java class i have a few print statements that are showing that the get methods are working


  • Registered Users Posts: 1,275 ✭✭✭bpmurray


    Well the syntax is right, so I'm confused as to why nothing is displayed. Actually, the naming convention you're using is unusual - are you sure it's getuser_name and not getUser_name or getUserName? Anyway, I'm assuming that your bean is OK - is that method something like this?
    public String getUser_name() {
       System.out.println("The user name = " + user_name);
       return user_name;
    }
    
    At least that'll show you what the value is.


Advertisement