0

I have a servelet called RegisterUser mapped as /register this servelet includes a jsp file called register.jsp . here is the structure of the project :

project structure

inside the servelet this code cannot find the jsp file :

        RequestDispatcher view = request.getRequestDispatcher(registerView);

and the content of registerView is :

    private static final String registerView = "../web/WEB-INF/views/Register.jsp";

It worked fine on eclipse but when I switched to Intellij it shows that the file cannot be found .

aouakki
  • 310
  • 5
  • 16
  • try with `private static final String registerView = "views/Register.jsp";` – Onur Jun 23 '16 at 13:37
  • @Onur still having the same error `[2016-06-23T13:40:30.398+0000] [glassfish 4.1] [SEVERE] [] [org.apache.jasper.servlet.JspServlet] [tid: _ThreadID=27 _ThreadName=http-listener-1(2)] [timeMillis: 1466689230398] [levelValue: 1000] [[ PWC6117: File "null" not found]] ` – aouakki Jun 23 '16 at 13:41
  • @Onur you're right the RequestDispatcher reffrs always to the web folder so the path of jsp files should be relative to this directory ..thank's you saved my day ! – aouakki Jun 23 '16 at 13:48

1 Answers1

1

Liferay has a somewhat strange layout for it's web-inf and html folders. In Eclipse I never really code path completion to work well in JSPs because it always looked at the wrong spot for files. In IntelliJ I just setup different facets that will help the IDE help me. Here is an example. I have a facet called WEB-INF. In Liferay, when you reference a file in WEB-INF (tagfiles are a GREAT example here) you do it like this:

<%@ taglib prefix="showMore" tagdir="/WEB-INF/tags/wj/showmore" %>

The problem there is that by default, the IDE wants to autocomplete like this:

<%@ taglib prefix="showMore" tagdir="/docroot/WEB-INF/tags/wj/showmore" %>

I simply made a web facet and said that when I type /WEB-INF I really want you to look at /docroot/WEB-INF. This small change saves me so much headache throughout the day. I also did the same thing with /html instead of /docroot/html.

You know how in eclipse when you go to an init.jsp file in the ext environment it always freaks about the init.jsp includes from portal because it can't find it? I once again used a web facet (called portal-web) and I linked / to /liferay/builds/4.3.x/portal-web/docroot. Now when I say:

<%@ include file="/

right there it starts autocompleting. It lists out everything in both portal-web and ext-web for me, because I have access to both inside Liferay! Doing this then:

<%@ include file="/html/common/init.jsp" %>

it's a problem, I can even click init.jsp and press ctrl (cmd) + b and it will jump me right into the init file in portal.

I tend to run IntelliJ with one "Module" and two "Content Roots". One content root is portal, the other is ext. The plus here is that the debugger knows about the portal source files, and I can easily jump between jsp files as well.

Resource Link:

Why I use IntelliJ instead of Eclipse?

SkyWalker
  • 28,384
  • 14
  • 74
  • 132