JPaS is a nano framework for creating traditional multi-page web apps in Java. Read more
JPaS supports three ways of including parameters in URL:
Link 1 href attribute looks like this: /jpas/demo?page=smartphone&id=000001
it is a traditional way to send parameters in GET request.
Link 2 href attribute looks like the follow /jpas/demo/page/smartphone/id/000001
it is a "static" URL loved by Google and generally preferable.
Notice, that page is required parameter that defines html template file.
Link 3 href attribute looks like the follow /jpas/demo/smartphone/000001
Parameters names was removed. Now, page parameter should always be first, just after servlet context.
Here is the server-side code:
public class SmartphoneView implements JpasView { @Override public String createHtml(HttpServletRequest request, HttpServletResponse response, Map<String, String[]> params, Document doc, JpasModel model) { //url contains parameters names - Link 1 and Link 2 //String smartphoneId = params.get("id")[0]; //url does not contains parameter names - Link 3 String smartphoneId = params.get("param1")[0]; Smartphone phone = ((SmartphoneModel) model).getSmartphoneById(smartphoneId); doc.select("head title").first().text(phone.title); doc.select("#title h2").first().text(phone.title); doc.select("#releaseDate h2").first().text(phone.releaseDate); doc.select("#memory h2").first().text(phone.memory); doc.select("#processor span").first().text(phone.processor); doc.select("#display span").first().text(phone.display); doc.select("#battery span").first().text(phone.battery); doc.select("#camera span").first().text(phone.camera); doc.select("#os span").first().text(phone.os); return doc.toString(); } }