URL Routes with Java Servlets

15 viewsexpressjavascriptjspnode.jsservlets
0

I wanted to know if there is a way to do similar code in java servlet like I do in express.js

In express I can say for example:

    app.get('/:name',function(bla bla)){}

the :/name its a parameter in which the url of the get can be

    localhost/kevin
    localhost/joe

or whatever… This is great because I can take then for example that name (request.params.name) and so something with it. And it is also great because there is no limit(As far as I know) as to how many routes I can create, it just serves as a placeholder.

Is there a way I can do this using Java servlets?? I want to be able to have an html page that when I click a button it goes to localhost/button1 If I click another button it goes to localhost/button2.. and so on.. But also I’m letting the user create buttons dynamically so I don’t want to create jsp pages beforehand, I just want the servletto create one..?

Thanks