This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JForum and the fly likes an attempt to access a non existing page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » JForum
Bookmark "an attempt to access a non existing page" Watch "an attempt to access a non existing page" New topic
Author

an attempt to access a non existing page

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi,
is there any way how to handle the situation when a user tries to access a non existing page (by editing the URL in browser - for examplea page http://localhost:8080/jforum/PageWhichDoesNotExist.page)?

Currently, if the user is not logged, there is a message that an error occured and a detail "java.util.ArrayList cannot be cast to java.lang.String". If the user is logged, surprisingly header.htm is automatically called as the first page to be included somewhere and in my case usually there is an exception because of some unimportant reason.

It would be nice to have some possibility to show a standart 404 page not found or something else useable. Is this possible? I would say it should be.

Thanks,
Roman

[originally posted on jforum.net by romant]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
What version of jForum are you using? My quick testing got 404 errors for non-existing pages.
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi,
I am using the last version, 2.1.8 of course. Yes, you can get 404 page not found if the non existing page you try to access does not end with ".page". But if it does the behaviour as I described in my previous post. And I think that it is not just my problem, it is the general behaviour, just try to access this site and you will see

http://www.jforum.net/forums/ANonExistingPage.page

Cheers.
Roman
[originally posted on jforum.net by romant]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
WHoops, sorry I tested on 2.1.7 and it worked... that gave me a starting point and I found that it looks like the WebRequestContext code has a bug about line 159. It calls the parseFriendlyURL method twice which set the module parameter to null twice... which converts it from a String to an ArrayList.

Anyway if you move this call into the if ( index > -1 ) condition above it, things should work as designed. E.g. The code should look like:



Not sure if Raphael is going to do a maint release on the 2.1.8, but if you add this as a Jira issue, it will probably make it into that release.
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Great,
thanks for the solution. I had my own fix, but this one is better.

Cheers,
Roman
[originally posted on jforum.net by romant]
 
jQuery in Action, 2nd edition
 
subject: an attempt to access a non existing page