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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

JSP Problem

  • 07-04-2006 12:00pm
    #1
    Registered Users, Registered Users 2 Posts: 1,771 ✭✭✭


    Hi All,

    If anyone could help me with this i'd really appreciate it...

    Basically I'm in a jsp page, and there's a form with username, password and a few more.
    What I need to do is assign the value of the password field to a java String.
    Is there a way of mapping javascript to a string, or any other way of accessing the form?

    Thanks.


Comments

  • Registered Users, Registered Users 2 Posts: 1,987 ✭✭✭Ziycon


    this goes in the page after the one with the password field.
    String password = request.getParameter("password feildname");
    


  • Registered Users, Registered Users 2 Posts: 1,771 ✭✭✭jebuz


    Ziycon wrote:
    this goes in the page after the one with the password field.
    String password = request.getParameter("password feildname");
    

    Thanks man, but I tried this one, returns null! basically i'm staying on the same page the whole time. Its just when a dropdown menu is changed, it reloads the page, but the text in the password field is lost everytime.

    What im doing is taking the text out of the password field, and encryping it, then passing it through as a parameter. The only way I seem to be able to retrieve the text is using javascript: form.userpassword.value.


  • Registered Users, Registered Users 2 Posts: 1,987 ✭✭✭Ziycon


    maybe try frames, one frame will have the pasword field and the drop down box and the other frame will be the frame that will change depending on whats in the dropdown box or password field!


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


    jebuz wrote:
    Its just when a dropdown menu is changed, it reloads the page, but the text in the password field is lost everytime.

    It sounds like you're doing a GET from the dropdown. If you do a submit (a POST), it'll send the stuff back to the server correctly, and put the field values into the reqest parameters, so you can use the suggested
    String password = request.getParameter("password feildname");
    

    So, the solution is NOT to react to the dropdown. When someone provides their username & password, they should click on a "Login" button. That's why it's so often done this way. If you still want to actually react to the dropdown, you need to execute form.submit() in JavaScript, or alternatively add the parameters to the URL when you send it to the server, but that's a HUGE security hole.

    BTW, if you're not familiar with GET and POST: these are the most common HTTP behaviours. Get is essentially the URL with the format http://foo.com?param=value&param2=value2, whereas POST is essentially the concept of sending the contents of a FORM to the server. A GET is almost always idempotent, i.e. you can call it agan & again and get the same result, whereas a POST typically cause data updates. That's why the GET doesn't work well in this situation.


Advertisement