Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Implementing Toy Web Server  RSS feed

Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've gotten some of the project working, but I have a few questions that I was hoping someone could answer:
We're give some classes to start with. Here's the relevant ones:

There's few parts I have questions about, but need most help in how to implement this class:

Blocker - Takes two arguments. The first argument is a string containing no white space and the second is a URL (e.g., Your code will retrieve the requested URL and determine whether the URL's contents contain the string given in the first argument. If the URL content does not contain the string return those contents to the client, passing on the Content-type it receives. Otherwise, return the string "Site blocked", passing Content-type:text/plain.

Once I have the url how do I parse through it's contents to see if the word is there? That's the part I'm unsure of.
Also, if I run it says listening on port xxxxx. How do I run a servlet from that point. They said the generic url would be I tried it and couldn't connect. Do I have to be on the school network to connect or do I need to add a few lines of code to run it?
Thanks for any help,
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!