本文介绍了它给出了空指针异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码&它在第62行提供了空指针异常action = request.getParameter("ACTION")&我不明白
所以有人可以帮我解决这个问题.............
谢谢....
I have the following code & it gives the null pointer exception on line no.62 action=request.getParameter("ACTION")& i''m not getting it
so can somebody help me through this.............
Thanx.......
<%@page import="java.util.ArrayList"%>
<%@page import="Ptech.Updation_Deletion"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
String user_id = (String)session.getAttribute("SID");
int id = Integer.parseInt(user_id);
String Name="";
String UserName="";
String Password="";
String From_Date="";
String To_Date="";
String Card_ID="";
String status="";
String company_name=(String)session.getAttribute("company_name");
String branch_name=(String)session.getAttribute("Branch_Name");
Updation_Deletion updel = new Updation_Deletion();
ArrayList al = new ArrayList();
al=updel.userUpdate_Delete(id);
if(!al.isEmpty())
{
//id=Integer.parseInt(al.get(0));
Name=(String)al.get(1);
UserName=(String)al.get(2);
Password=(String)al.get(3);
From_Date=(String)al.get(4);
To_Date=(String)al.get(5);
Card_ID=(String)al.get(6);
status=(String)al.get(7);
System.out.println("UID"+id);
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form action="For Updation_Deletion.jsp" method="post">
<table border="1" width="200">
<tr><td>Name:</td><td><input type="text" name="NAME" value="<%=Name%>"/></td></tr>
<tr><td>UserName:</td><td><input type="text" name="USERNAME" value="<%=UserName%>"/></td></tr>
<tr><td>Password:</td><td><input type="text" name="PASSWORD" value="<%=Password%>"/></td></tr>
<tr><td>From_Date:</td><td><input type="text" name="FROM_DATE" value="<%=From_Date%>"/></td></tr>
<tr><td>To_Date:</td><td><input type="text" name="TO_DATE" value="<%=To_Date%>"/></td></tr>
<tr><td>Card_ID:</td><td><input type="text" name="CARD_ID" value="<%=Card_ID%>"/></td></tr>
<tr><td>Status:</td><td><input type="text" name="STATUS" value="<%=status%>"/></td></tr>
<tr><td>Company_Name:</td><td><input type="text" name="COMPANY_NAME" value="<%=company_name%>"/></td></tr>
<tr><td>Branch_Name:</td><td><input type="text" name="BRANCH_NAME" value="<%=branch_name%>"/></td></tr>
</table>
<input type="submit" name="ACTION" value="Edit"/>
<input type="submit" name="ACTION" value="Delete"/>
<input type="button" name="BACK" value="Back"/>
<%
String action ="";
if(!action.equals(null))
{
action= request.getParameter("ACTION");
if (action.equals("Edit")) {
session.setAttribute("Tr_Flag", "U");
System.out.println("IF");
} else if (action.equals("Delete")) {
session.setAttribute("Tr_Flag", "D");
} else {
session.setAttribute("Tr_Flag", "I");
}
}
%>
</form>
</body>
</html>
推荐答案
<input type="submit" name="ACTION" value="Edit"/>
<input type="submit" name="ACTION" value="Delete"/>
尝试为每个输入使用不同的名称
Try with different name for each input
这篇关于它给出了空指针异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!