0

I Have this HTML tag

<button type="submit" name=<%=s %> value=<%=s %>><%=s%></button>

The <%=s %> is a String stored in server with white spaces, like "file one".

My problem is in getting the button name. I'm using the following piece of code:

String btnName = request.GetParameter(s);

It is working, unless if the string presents spaces like "file one". In this case, the part " one" is ignored.

How can I get the whole String?

Thx.

2
  • 2
    Attributes should be in quotes, and you should be using EL instead of scriptlets. Commented Apr 3, 2013 at 3:24
  • I'm not sure about this, but did you try surrounding it within double quotes? Commented Apr 3, 2013 at 3:25

1 Answer 1

1

Put it like the following.

<button type="submit" name='<%=s %>' value='<%=s %>'><%=s%></button>

Note the new single quotes.

Sign up to request clarification or add additional context in comments.

6 Comments

I'll heavily suggest you to read/study How to avoid Java Code in JSP-Files?.
@LuiggiMendoza The problem would still remain even if they use EL or JSTL, as long as they don't have quotes.
The problem is that name attribute should not contain any spaces =\. Note that OP has this s String with a value like file one.
@LuiggiMendoza Not necessarily. try this <html> <body> <form> <button type="submit" name='my name' value='ha ha ha'>test ok</button> </form><script language='javascript'>alert(document.forms[0]['my name'].value);</script> </body> </html>
test it on your servlet :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.