• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

dynamic action attribute of a form  RSS feed

 
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 ]
 
Marshal
Posts: 67164
169
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
Marshal
Posts: 67164
169
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!