aspose file tools*
The moose likes Servlets and the fly likes changing form's target attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "changing form Watch "changing form New topic
Author

changing form's target attribute

Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Hello,
we have <form name="" action="" target="">
Is it possible to set / change the value of target attribute in my service method of the servlet, so that i can control when to open the output in a new window.
I have a situtation where i have to decide(whether to open a new window or display the result in same window) after retrieving request parameters. I am confused, plz help
thanks


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

servlet processing happens server-side, after the form has been submitted. The target has already been remembered by the browser, and the response the servlet sends back will appear either in the same window or a different one. This is up to the browser, and there is nothing your servlet can do about it.

One option is to use javascript in your original form to dynamically change the target attribute, based on what the user selects or enters. This would happen before the form is submitted.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: changing form's target attribute