-
Call JSP/Servlet from java program? (2 messages)
- Posted by: Chee Seng Yee
- Posted on: March 08 2001 08:31 EST
Can a java program call a JSP or servlet, or EJB??
Thank you.Threaded Messages (2)
- Call JSP/Servlet from java program? by Mike Sprague on March 08 2001 22:15 EST
- Call JSP/Servlet from java program? by adafaf dafaf on February 18 2012 08:56 EST
-
Call JSP/Servlet from java program?[ Go to top ]
- Posted by: Mike Sprague
- Posted on: March 08 2001 22:15 EST
- in response to Chee Seng Yee
Yes, You use the URL class and point it to your
servlet or JSP URL.
InputStreamReader isr = new InputStreamReader(System.in ) ;
BufferedReader br = new BufferedReader(isr);
String line = br.readLine() ;
URL url = new URL( "http://localhost:7001/reverse.jsp" ) ;
URLConnection connection = url.openConnection() ;
connection.setDoOutput(true) ;
// The order in which input and output strams are acquired matters.
ObjectOutputStream os = new ObjectOutputStream( connection.getOutputStream() ) ;
os.writeObject( line ) ;
os.close() ;
ObjectInputStream is = new ObjectInputStream( connection.getInputStream() ) ;
System.out.println( is.readObject() ) ;
is.close() ;
-
Call JSP/Servlet from java program?[ Go to top ]
- Posted by: adafaf dafaf
- Posted on: February 18 2012 08:56 EST
- in response to Mike Sprague
Yes, You use the URL class and point it to your
servlet or JSP URL.
InputStreamReader isr = new InputStreamReader(System.in ) ;
BufferedReader br = new BufferedReader(isr);
String line = br.readLine() ;
URL url = new URL( "http://localhost:7001/reverse.jsp" ) ;
URLConnection connection = url.openConnection() ;
connection.setDoOutput(true) ;
// The order in which input and output strams are acquired matters.
ObjectOutputStream os = new ObjectOutputStream( connection.getOutputStream() ) ;
os.writeObject( line ) ;
os.close() ;
ObjectInputStream is = new ObjectInputStream( connection.getInputStream() ) ;
System.out.println( is.readObject() ) ;
is.close() ;Hey man...
I have a class SampleLogin.java. From SampleLogin.Login(), i should redirect call to a JSP, which loads applet, and read input from it and get the control back to SampleLogin.login(). How to achieve this??
Suggestions are highly praised.