• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

want to open response.sendRedirect in a new window

 
Prasenjit Das
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks,
i am using this line in my code
response.sendRedirect("http://www.google.com/search?q="+str_search+" + Maharashtra + India");
this works, I want to open this in a new window. so i tried like this -
response.sendRedirect("%><script language="javascript">window.open("http://www.google.com/search?q="<%=str_search%>" + Maharashtra + India")</script><%");
but this is giving me the following errors :
Error(29,33): illegal character
Error(29,33): unclosed character literal
Error(29,158): unclosed character literal
Error: malformed expression
I am not being able to correct.
Can anybody help me regarding this.
Thanks a lot in advance.
regards,
Prasen
 
Navin Thr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just make a few changes to your view.
try putting in the target attribute
if it is a form submit action,
<form method="post" action="someAction" target="_blank">
if it is a link,
<a href="someAction?key=value" target="_blank">Click here</a>
Regards,
Navin
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Navin indicated, you must target the original request to the window in which you want the response to appear. Once the request has been made, there is no way to change the window in which its response will be displayed.
 
Prasenjit Das
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GREAT GUYS!!! IT WORKS!!!
So, is it like a mantra- that whenever u want to open the request.sendRedirect in a new window put in the target attribute inside the form tag.
Thanks a lot,
Cheers.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic