• Post Reply Bookmark Topic Watch Topic
  • New Topic

dynamic action attribute of a form  RSS feed

 
ying lam
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to do something like this:

If the 'Accept-Language' of the http request is 'en', write out this in JSP:
<form name='myform action="http://127.0.0.1/myservlet/en/>
else if
the 'accept-language' is 'es', write out this instead:
<form name='myform action="http://127.0.0.1/myservlet/es/>

else if no match
<form name='myform action="http://127.0.0.1/myservlet/default/>

How can I do that in JSP? I think this is simple enough so that I don' t need to use any of the Java Web framework/Java Beans.

Thank you for any help.
[ October 26, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like you've worked out the solution for yourself.

Use conditionals to determine what URL is to be placed in the form action, and then use that in the <form> tag.

What's the issue?

If you're looking for someone to write the code for you, you may be in the wrong place.

Why not try to write the code yourself and then post it here with any questions or problems you might be having.
 
ying lam
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Only the last part of the action attribute is different.
i.e. all 3 cases this is the same '<form name='myform action="http://127.0.0.1/myservlet/'

only difference is
'en\">'
'es\">'
'default\">'

but I don't know how to write incomplete xml tag using JSP.

Thanks for any help.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, first of all we need to know what versions of JSP and JSTL you are using (as per forum instructions).

At this point you should be using a JSP 2.0 container unless you've got a a really good reason not to be.

Secondly, remember that to a JSP, HTML markup is not XML -- it's just template text. So you don't need to worry about it being incomplete or syntactically correct in the JSP. Only when the renderred HTML is sent to the browser does completeness matter.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!