Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing last user page in DB

 
Prasad Rachakonda
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my project we have to store user's currently displayed page content(html code) in DB. This is useful for CSR to see user's current page. I'm planning to use servletFilter's concept but not sure how to get the html code as a stream/string inorder to store in DB. I appreciate any suggestions/comments?
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use following code to get the HTML:
try {
URL url = new URL("http://www.somesite.com/eng/index.htm");
DataInputStream in = new DataInputStream(url.openStream());
InputStreamReader r = new InputStreamReader(in);
BufferedReader reader = new BufferedReader(r);
String line = null;
while((line = reader.readLine()) != null){
System.out.println("LINE : " + line);
}
}
catch (Exception ex) {
}
 
Brahim Bakayoko
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a filter with a response wrapper then save the data before sending to the user.
You can use this as a jumpstart:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic