Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Jsp Html question

  • 28-03-2006 03: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, Registered Users 2 Posts: 27,508 ✭✭✭✭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, Registered Users 2 Posts: 6,422 ✭✭✭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, Registered Users 2 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, Registered Users 2 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