I have x.jsp that can either be served as the whole response, or being included in several other jsp files.
So how can I know inside x.jsp if it is being included by another file or not?
I have x.jsp that can either be served as the whole response, or being included in several other jsp files.
So how can I know inside x.jsp if it is being included by another file or not?
You can check the value of the attribute javax.servlet.include.request_uri in your x.jsp page. If set, the jsp page was included.
Further details here: Java HttpServletRequest get URL in browsers URL bar
You can have a hidden field in the 'other files' and if you are including x.jsp you should set a value for it, and within x.jsp when you wanna know if its including you should check if that hidden fields value == 'value'.
If x.jps have knowledge about inclusion, it means that some best practices is ignored:
x.jsp is not just a view, but also some kind of controller. x.jsp to y.jsp and z.jsp, or introduce a variable which will contain value for appropriate casex.jsp needs additional data about enviroment. Of course these practices are not mandatory but you need a strong reason why you ignore them.
Please give us more information about your case or rephrase you question
Edit
My answer is abstract as your question is abstract. Get us your jsp, what should be changed and I hope you get better answer.