This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 684

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: 41092
    
  44
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
 
Consider Paul's rocket mass heater.
 
subject: Is it possible? Take html source code from a jsp
 
Similar Threads
How to convert JSP into a txt or html file?
I need help with my very first jsp
viewable .jsp / .java source on my website
How can I write jsp lib that removes html tag
making source code viewable on my website