6

I am writing a web-server using Tomcat. The tech i decided to use is JSTL.

I want to first say that it works, the page displays successfully and everything runs. I do like to get rid of warnings. The warning i get from intelliJ is: "Cannot resolve variable ''", it comes from a JSP page where i have some JSTL code. The jsp page is called from my controller using RequestDispatcher forward function.

request.setAttribute("resultsModel", resultsModel);
request.setAttribute("times", times);
request.setAttribute("emailErr", emailErr);
request.setAttribute("qid", id);
RequestDispatcher view = request.getRequestDispatcher("ShowResults.jsp");
view.forward(request, respone);

The JSP page then uses this variables in a variety of JSTL tags, example from page:

<c:choose>
<%-- When database access was succesfull --%>
<c:when test="${resultsModel != null}">
    <c:choose>
        <%-- When the job ID exists --%>
        <c:when test="${resultsModel.jobEntity != null}">

ect...

The warning is then given on those positions where i try to access resultModel. I tried adding a jsp:useBean tag as such:

<jsp:useBean id="resultsModel" scope="request" type="bgu.bioinf.rnaSequenceSniffer.Model.ResultsModel"/>

But I still get a warning. Any idea? Something i am doing really wrong? Thanks!

Matan Drory
  • 63
  • 1
  • 6
  • You can press Alt-Enter to select a QuickFix, did you tried this? – Semih Eker Dec 14 '14 at 22:02
  • 1
    If everything works fine, then leave it as it is. Don't pollute your code with useless code just to make your IDE happy. It tries to figure out possible mistakes, and fails at doing so. Accept it. You're smarter than the IDE. – JB Nizet Dec 14 '14 at 22:19
  • QuickFix has nothing on it. I am ignoring it ATM, it just that my last boss really imprinted in me the need to compile with 0 warning, they might hide some real error some times. – Matan Drory Dec 16 '14 at 14:35
  • Try to find an answer before ask the question... Solution is [here](http://stackoverflow.com/questions/12694392/intellij-not-resolving-el-variables-within-jsp-code-inspection-or-autocomplete) – Андрей Ковальчук Jun 08 '16 at 06:01

2 Answers2

1

I meet this question too, and really bother me. Today I googled this problem and find no solution. However I used the ModelMap rather than HttpServletRequest.

map.put("info",info);

And no doubt I got this warning,then I changed the method:

map.addAttribute("info",info);

I want to say this way does solve the warning,you can even ctrl + button1 to navigate the bean in the controller. I don't know if this solve the problem in other scenario,But in intellij 2018.1 I just get rid of it.Hope it works for you

JXmb
  • 35
  • 9
0

Go to Project Structure | Libaraies | Add | From Maven search javax.servlet:jstl, then select javax.servlet:jstl:1.2.

My version is latest.

DimaSan
  • 12,264
  • 11
  • 65
  • 75