This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSP and the fly likes How do you call a jsp page from a regular java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How do you call a jsp page from a regular java program" Watch "How do you call a jsp page from a regular java program" New topic
Author

How do you call a jsp page from a regular java program

Hemal Mehta
Ranch Hand

Joined: Nov 16, 2000
Posts: 101
How do you call a jsp page from a regular java program. Also I need to get the resukts from this jsp page and parse it...
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

You can contact a JSP by invoking the _jspService method. But, realize that this takes the HttpSerlvetRequest and HttpServletResponse as parameters.

Instead, you can use an API like HttpUnit to create a request object and invoke the JSP through that. It also give you the ability to receive the response.
Check out the HttpUnit website for more information and usage, especially the HttpUnit Cookbook
[ April 22, 2002: Message edited by: Jessica Sant ]

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Hemal Mehta
Ranch Hand

Joined: Nov 16, 2000
Posts: 101
Whya can't we use Class URLConnection for this issue?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15627
    
  15

Originally posted by Hemal Mehta:
Whya can't we use Class URLConnection for this issue?

As far as I know, you should. HttpUnit was designed for unit testing. The only reason I can think of for using something external to the basic JDK would be if HttpURLConnection wasn't providing some of the side protocols, and in the case of Applets, at least, even the cookies are taken care of by HttpURLConnection.
Just a quick look over HttpUnit gives me the impression that the extras that HttpUnit provides are for easing the composition and decomposition of HTML, XML, or other content. It's very likely that HttpUnit relies on HttpURLConnection itself.
I think _jspService, BTW is the name some JSP compilers give the internal entry into the compiled JSP - you'd only really want to call that yourself if you're short-circuiting the servlet container and locally calling into the JSP.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you call a jsp page from a regular java program
 
Similar Threads
JSP, Java Beans, and classes
java jsp
dynamic java
EJB and JSP
How to retrive values from the database