I am using JSP with NetBeans and I am getting the following error

Note:

C:\Users\Greg\Documents\NetBeansProjects\abalon3\build\generated\src\org\apache\jsp\user2_jsp.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

the code:

<%
  String like=" ";
  Vector<String> vcd = new Vector<String>();
  Vector<String> vbo = new Vector<String>();
  vcd=CheckUser.search_latest_cd();
  int jc=vcd.size();
  vbo=CheckUser.search_latest_books();
  int jb=vbo.size();
  int i=0;

%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<table border="1" cellspacing="10"
bgcolor=#99FFFF>
<tr>
<th>Author</th>
<th>Title</th>
<th>Summary</th>
<th>Genre</th>
<th>year</th>
<th>Price</th>
<th>ID</th>
</tr>
<%if(vbo.size()>0){for( i=jb;i<jb;i-=7){%>
<tr><td><%out.print(vbo.get(i-6));%></td><td><%out.print(vbo.get(i-5));%></td>
<td><%out.print(vbo.get(i-4));%></td><td><%out.print(vbo.get(i-3));%></td>
<td><%out.print(vbo.get(i-2));%></td><td><%out.print(vbo.get(i-1));%></td>
<td><%out.print(vbo.get(i));}}%></td></tr>
</table>

can anyone tell me where is the problem?

+3
source share
3 answers

Try to do what the message says:

Compile with -Xlint: unchecked for details.

+1
source

Do vcd=CheckUser.search_latest_cd();and vbo=CheckUser.search_latest_books();return Vector<String>?

The reason for this is unchecked or unsafe operationsusually because the compiler cannot check the generictype type. Read here for more information.

Additionally, Java is Vectordeprecated in a later version of the JVM. You should consider using ListandArrayList

: , . :

Vector<String> vcd = new Vector<String>();
vcd=CheckUser.search_latest_cd();

vcd:

Vector<String> vcd = CheckUser.search_latest_cd();

Vector<String> vcd = null;
vcd=CheckUser.search_latest_cd();

Vector, , .

+1

And last but not least, what you see is not an error, but a warning from the compiler (although some compilers can be configured to handle warnings as errors, this is not the default behavior of the Sun Java compiler).

0
source

Source: https://habr.com/ru/post/1792379/


All Articles