You should never put any class in the root package.
Once you have put your Sample class in a package (example: com.foo.andy.sample
), you need to declare the servet in the web.xml of your web application, and declare one (at least) mapping for this servlet.
You might follow this tutorial to know how to do it.
You need these lines in the web.xml:
<servlet>
<servlet-name>SampleServlet</servlet-name>
<servlet-class>com.foo.andy.sample.Sample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SampleServlet</servlet-name>
<url-pattern>/pages/Sample</url-pattern>
</servlet-mapping>
And your servlet will be accessible at .../yourWebApp/pages/Sample