Just to complete the topic for others that want to do the same thing as me, here's the basic code in my Servlet.
It looks for usernames first as a sub-domain, then in the path, so the following URLs will all be handled properly. http://username.domain.name/ http://domain.name/username http://username.domain.name/somethingElse The last instance allows the Servlet to get the username from the sub-domain and also a path value that could point to a specifc page within the user's profile. I've only posted the code that has been changed or added. Merge this with the full code I published above. | import java.net.URL; | | public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | | String profile = "blank"; | StringBuffer sb = request.getRequestURL(); | URL url = new URL(sb.toString()); | String host = url.getHost(); | String sSplit[] = host.split("\\."); | if(sSplit[0].compareTo("domain") == 0) // no sub-domain in hostname | profile = request.getPathInfo(); // path should be username | else | profile = sSplit[0]; // sub-domain should be the username | | | response.setContentType("text/html"); | PrintWriter out = response.getWriter(); | out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); | out.println("<HTML>"); | out.println("<HEAD><TITLE>Member Bio for " + profile + "</TITLE></HEAD>"); | out.println("<BODY>"); | out.println("<h1>Member Bio for " + profile + "</h1>"); | out.println("</BODY>"); | out.println("</HTML>"); | out.flush(); | out.close(); | } | | public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | doGet(request, response); | } | View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3874314#3874314 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3874314 ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ JBoss-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jboss-user
