//myscript.jsp
//http://www.domain.tld/myscript.jsp/this_is_words
urlpath = req.getParam("REQUEST_URI");
String[] words = urlpath.split("/");
String firstvariable = words[4];
%>

<%=firstvariable%>
<!-- this is words should be printed above)