• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Very tricky question

 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks
I tried my best but cud not come to any conclusion
Can any one tell me that if on click of submit button when i call a servlet .if i want that servlet to be opened in a new window instead of the same browser is it possible
if yes cana anyone pls tell me how it is possible
i tried it thru calling a function on the event onSubmit but that also donot serve the purpose
Thnkx in advance for any of your views
Gaurav
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its possible using Javascript
I exactly do not know the syntax in Javascript
it should be like window .open() which opens a new window and I hope you can also pass the pass the url as parameter of the servlet that you would want to be evoked or a html pages
Regards
 
Gaurav Chikara
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi narayan
i appreciate ur reply
but thru javascript it is only possible if we are not using submit button but i m using submit button and on its click
only one operation is performed and that is invoking of the servlet with in same browser
so my problem is still confusing even if i use onClick on submit button then also popup window opens but simultanously the servlet gets called with in the same browser
any other views are welcome
Gaurav

Originally posted by narayan kulkarni:
Its possible using Javascript
I exactly do not know the syntax in Javascript
it should be like window .open() which opens a new window and I hope you can also pass the pass the url as parameter of the servlet that you would want to be evoked or a html pages
Regards


 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just tried this for you. The following is the html and servlet code for your perusal. I think it meets your requirement(opens servlet in a new window)
HTML Code
----------
<HTML>
<HEAD>
<TITLE>TESTING</TITLE>
</HEAD>
<BODY bgcolor=white>
<FORM name="Form" onSubmit="return func();" >
<center><b>
ID Number:�<input type="text" name="Userid" value="Ajan" SIZE=20 MAXLENGTH=9 ><br>
Password���:�<input type="password" name="Password" value="ferrari" SIZE=20><br>

</B></center>
<h1 align=right>
<input type="submit" value="Done">
<input type="Reset" value="Cancel">
</h1>

</FORM>

<Script language="JavaScript" >

function func()
{
var var1 = Form.Userid.value;
var var2 = Form.Password.value;
var var3 = "http://localhost:8080/servlet/PostServlet?Userid="+ var1 +"&Password="+ var2;

window.open(var3, "hello");
return true ;
}

</script>

</BODY>
</HTML>
Servlet Code
------------
import java.io.IOException;
import java.io.*;
import java.util.Properties;
import javax.servlet.*;
import javax.servlet.http.*;
public class PostServlet extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException
{
doPost(request,response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException
{
String userId = request.getParameter("Userid");
String password = request.getParameter("Password");
PrintWriter out = response.getWriter();
out.println(userId);
out.println(password);

}
}

Hope this helps

Ajan
[This message has been edited by Ajan Balakrishnan (edited February 01, 2001).]
[This message has been edited by Ajan Balakrishnan (edited February 01, 2001).]
 
Gaurav Chikara
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thnkx ajan
it really resolved my doubts
i m thankful to ya
have a nice day
Gaurav

Originally posted by Ajan Balakrishnan:
I just tried this for you. The following is the html and servlet code for your perusal. I think it meets your requirement(opens servlet in a new window)
HTML Code
----------
<HTML>
<HEAD>
<TITLE>TESTING</TITLE>
</HEAD>
<BODY bgcolor=white>
<FORM name="Form" onSubmit="return func();" >
<center><b>
ID Number:�<input type="text" name="Userid" value="Ajan" SIZE=20 MAXLENGTH=9 ><br>
Password���:�<input type="password" name="Password" value="ferrari" SIZE=20><br>

</B></center>
<h1 align=right>
<input type="submit" value="Done">
<input type="Reset" value="Cancel">
</h1>

</FORM>

<Script language="JavaScript" >

function func()
{
var var1 = Form.Userid.value;
var var2 = Form.Password.value;
var var3 = "http://localhost:8080/servlet/PostServlet?Userid="+ var1 +"&Password="+ var2;

window.open(var3, "hello");
return true ;
}

</script>

</BODY>
</HTML>
Servlet Code
------------
import java.io.IOException;
import java.io.*;
import java.util.Properties;
import javax.servlet.*;
import javax.servlet.http.*;
public class PostServlet extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException
{
doPost(request,response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException
{
String userId = request.getParameter("Userid");
String password = request.getParameter("Password");
PrintWriter out = response.getWriter();
out.println(userId);
out.println(password);

}
}

Hope this helps

Ajan
[This message has been edited by Ajan Balakrishnan (edited February 01, 2001).]
[This message has been edited by Ajan Balakrishnan (edited February 01, 2001).]


 
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic