Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Next button and retrieving the name of the JSP's  RSS feed

 
Jhon Calado
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi everybody,

I'm building my website and found a little problem that shouldn't be difficult to solve but I just can't seem to get over it.

I want to have a button in my Jsp's labeled "next" that takes me to the next JSP in a certain order. Imagine a book: every time you click next you go to the next page.
Each page is a JSP that is named "page#" where # stands for the number (page1, page2,etc).

I was structuring my app this way: one controller,one controllerhelper,multiple JSPs.

The "next" button in the JSP's would always have the same name as not to overcode in my controllerhelper with too many options for the button that was pressed.

So my idea was to retrieve the name of the current JSP and work the string in order to add a number (page4 turns into page5) and forward it through a requestdispatcher.

That is the problem as I am not able to get the name of the current JSP since the url changes after the first page to the servlet url.

Any help will be appreciated (including pointing out basic concepts that I am not understanding).
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using there name of the JSP is not a good way to do this. In fact, with a properly constructed controller, the name of the JSP will never be part of a URL.

I would map the URL of the controller to something like /page/1, /page/2, /page/3 and so on.

The page number would be part of the path info which you can easily retrieve from the request instance.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!