0

I am trying to view some parameters in a jsp file. I send these parameters from a Java servlet with using the code below:

req.setAttribute("x", account.entities.getX());
req.setAttribute("y", account.entities.getY());
context.getRequestDispatcher("/Home.jsp").forward(req, resp);

In Home.jsp file I want to view these parameters in a table and I used the code below:

<thead>
    <tr>
        <th>Header1</th>
        <th>Header3</th>
    </tr>
</thead>
<tbody style="text-align: center">
    <tr>
        <td>XName</td>
        <td>${x}</td>
    </tr>
    <tr>
        <td>YName</td>  
        <td>${y}</td>
    </tr>
</tbody>

But when I run my web application on Tomcat Server, these parameters looks like exactly how I type these in jsp file. (This: ${y} ${x}) And when I bring the cursor on these, I got this message: This inspection reports possible el problems such as unresolved references an invalid el locations.

In here, it says:

You can use Alt+Enter shortcut to invoke intention "Declare external variable in comment annotation" in order to get rid of "unresolved model attribute" in your views.

It automatically adds the below code when I try that:

<%--@elvariable id="x" type="What should be here"--%>
<%--@elvariable id="y" type="What should be here"--%>

But I do not know what to write in type part and I am not sure if it is the right solution or not. What should I do?

JollyRoger
  • 737
  • 1
  • 12
  • 38
  • try with request.getParameter(x); And if you are using strut2 then you can use like this – Hiten Jan 30 '18 at 06:41
  • @chrylis It is not for an assignment but I need to learn this way of making Web applications. Do you have any suggestions about my problem? – JollyRoger Jan 30 '18 at 07:17
  • @Hiten Do you mean this: <% request.getParameter(x) %>. It did not print anything on jsp file. And I am not using strut2. Any other way to do that? – JollyRoger Jan 30 '18 at 07:18
  • <%= request.getParameter(x) %> try with this. – Hiten Jan 30 '18 at 07:45
  • @Hiten Actully this: https://stackoverflow.com/questions/30080810/el-expressions-not-evaluated-in-jsp solved my problem. Thanks anyway. – JollyRoger Jan 30 '18 at 07:49

0 Answers0