Simple JSP question

Sharky Forums


Results 1 to 6 of 6

Thread: Simple JSP question

  1. #1
    Tiger Shark
    Join Date
    Nov 2000
    Location
    Canada
    Posts
    811

    Post Simple JSP question

    How can I read the values of a TEXT FIELD within a JSP? What is the code that can access the text field?

    I don't want to pass the values by session to itself.

  2. #2
    Reef Shark mefisto3's Avatar
    Join Date
    Jul 2001
    Location
    Melbourne, Vic, Australia
    Posts
    429
    I am not exactly sure what you want to do. You cant access the text field from a JSP. If you need to access the text field you should probably use JavaScript.

    Could you give more info?

  3. #3
    NullPointerException rock's Avatar
    Join Date
    Sep 2000
    Location
    York, PA
    Posts
    6,203
    Prince, I guess our conversation died in the conversion. Have you looked at examples in a tomcat 3.3 install under webapps/examples/jsp?

    For the record, the syntax is something like:

    calling html: <INPUT NAME=USER TYPE=TEXT VALUE=bob>

    target jsp: <%= request.getAttribute("USER") %>

    but the method can depend on your servlet.

    Open Source is free like a puppy is free.

    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.

    Understanding Evolution

  4. #4
    Tiger Shark
    Join Date
    Nov 2000
    Location
    Canada
    Posts
    811
    I didn't want to pass the variables to a page and then evaluate value . I wanted to evaluate value, on-the-fly in JSP.
    I guess i am going to have to use Javascript and combine with JSP.

    I am somewhat new to Java. Don't like it so much. It has its strong points, but it is a pain because no really really good IDE out there for it yet. After trying as many as i can, Jbuilder is the only one i can cope with. But even with Jbuilder, there are some things that you just have to its way, or it gives you stupid errors.

    Don't like Java interface, so used to Microsoft GUI that hard to get used to it. Java does look the same, but its feel is different (not to mention the reaction time), i am running a 500Mhz. It should be just fine on faster machines, but this 500Mhz is all i got rite now.

  5. #5
    Reef Shark mefisto3's Avatar
    Join Date
    Jul 2001
    Location
    Melbourne, Vic, Australia
    Posts
    429
    Yeah, the Java IDE definitely sucks. I use JBuilder too at work and at home, and it is so bloody slow (i have a celery 600 at work and a pIII at home). Everytime i run JBuilder my computer does a lot of swapping (i have 128 MB at work). At home its not too bad (512 MB).

    Anywya, if you want to access the Text Field, u need to use JavaScript. JSP (being server side) have no access to the texf field.

  6. #6
    NullPointerException rock's Avatar
    Join Date
    Sep 2000
    Location
    York, PA
    Posts
    6,203
    You could force the jsp to call itself if the object comes back NULL:

    <% if ( request.getAttribute("USER") == null ) { %>
    <script language="JavaScript1.1">
    location.replace('/webapps/servlet/Servlet?jsp=/jsp/target.jsp&user=<%= request.getAttribute("USER") %> ')
    </script>
    <% } %>

    Or something like that - I just pieced that together on the fly and doesn't look quite right to me....

    Open Source is free like a puppy is free.

    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.

    Understanding Evolution

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •