aspose file tools*
The moose likes JSP and the fly likes Is it possible? Take html source code from a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Is it possible? Take html source code from a jsp" Watch "Is it possible? Take html source code from a jsp" New topic
Author

Is it possible? Take html source code from a jsp

matias casal
Ranch Hand

Joined: Oct 18, 2009
Posts: 61
Hello, is it possible to take the html source code from a jsp with a function, or header ?
Thank you
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
What do you mean by this? A JSP page is really just an HTML page with tags in it.

Perhaps if you could show what your expected result is, or explain more of what you're trying to do?

matias casal
Ranch Hand

Joined: Oct 18, 2009
Posts: 61
My objective is to get the html source (<html><body>...</body></html>) with a function or something like that to put it on a mysql table.
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 686

matias casal wrote:Hello, is it possible to take the html source code from a jsp with a function, or header ?
Thank you
.

Yes ..you can...Use java HttpClient .

you just have to set URL, method type (Get or Post) and respective parameters. If your page set cookie then you have to set cookie value. using this class you can get the HTML page of any application in Stream and then convert it to text and use as per your requirement. If you have to get any specific data from the result page then you can also HTML parse the page using HTMLEditorKit class.


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
matias casal
Ranch Hand

Joined: Oct 18, 2009
Posts: 61
Oh, thank you, but I didnt understand your answer.
have you got any tutorial about HttpClient ?
Thanks again!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41800
    
  62
The HttpClient web site contains numerous examples.


Ping & DNS - my free Android networking tools app
Tomasz Szymanski
Greenhorn

Joined: Jan 11, 2010
Posts: 23
Or you could simply use the RequestDispatcher.include method. Although "simply" might not be the best word, because I guess you would have to pass your own ServletResponse object that would let you capture the result (see the javax.servlet.ServletResponseWrapper class). But it still looks a bit simpler than HttpClient to me.
matias casal
Ranch Hand

Joined: Oct 18, 2009
Posts: 61
Thank you, I will read about this
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible? Take html source code from a jsp