I'm pretty new to Java so bear with me. Basically I have a class named "returnPages" that returns the parent page that you are currently on. The problem is when you're at the highest level or the root it throws an error, logically because the root doesn't have a parent it will throw a null pointer exception. How would I prevent an error being thrown when your at the root? I thought the below code would work but I'm simply getting a null pointer exception were I start my conditional. Note: I'm trying to run this in the JSP, modifying the returnPages class will result in multiple conflicts across the site. Also the returnPages class takes two arguments the first is parent page followed by the current page your on.
Page rootPage = properties.get("rootPage", "");
if(returnPages.getPath(rootPage, currentPage) != null){
List<Page> trail = returnPages.getPath(rootPage, currentPage);
} else {
//show something here
}
Any help is greatly appreciated!