Home  >  Article  >  Java  >  What is 500 error in jsp

What is 500 error in jsp

(*-*)浩
(*-*)浩Original
2019-05-29 11:28:117892browse

The jsp interface I wrote yesterday encountered such a problem. A 500 error occurred every time it was accessed. It was an abnormal error in the java code. After debugging for a long time, I didn't find any problem with the code, and I felt very desperate.

What is 500 error in jsp

The error message is as follows:

What is 500 error in jsp

The code is as follows:

<div>
     list = (ArrayList<jsonobject>)request.getAttribute("newsList");
        for(JSONObject j: list){

    %>
    <a>"></a>
    <p>...</p>

    
</jsonobject>
</div>

According to the error message, I found that the problem lies in this line of code:

ArrayList<jsonobject> list = (ArrayList<jsonobject>)request.getAttribute("newsList");</jsonobject></jsonobject>

Intuitively, there is no error, and the parameter name in request.getAttribute("newsList") is not wrong either.
The corresponding servlet also reads the contents of the database.
Why is a 500 error reported?

The code is modified as follows:

<div>
     list = (ArrayList<jsonobject>)request.getAttribute("newsList");
        if (list != null && list.size()!=0){
            for(JSONObject j: list){

    %>
    <a>"></a>
    <p>...</p>

    
</jsonobject>
</div>

That is, non-empty judgment is made between directly traversing the printing list! ! !
This also provides me with great inspiration for writing code in the future.
There is still a long way to go in terms of code specifications, coding habits and code rigor! ! !

The above is the detailed content of What is 500 error in jsp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn