getting null value in action from ajax call
Getting null value from ajax call in action (FirstList.java)... first list is loading correctly. Need help, i am new to struts2 and hibernate.
StudentRegistration.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="/struts-dojo-tags" prefix="sx"%>
<html>
<head>
<sx:head />
<title>Student Registration</title>
</head>
<script>
function show_details() {
dojo.event.topic.publish("show_detail");
}
</script>
<body>
<s:form id="form1" name="form1" action="StudentRegister" method="post" enctype="multipart/form-data" theme="simple">
<s:hidden name="id" />
<table border="0">
...
<tr>
<td><s:label value="Course " for="course" /></td>
<td><s:select name="course" list="courseList" onchange="javascript:show_details();return false;" /></td>
</tr>
<tr>
<td colspan="2"><s:url id="durl" action="secload" /><sx:div showLoadingText="" id="details" href="%{durl}" listenTopics="show_detail" formId="form1" ></sx:div></td>
</tr>
<tr>
<td align="center" colspan="2"><s:submit /></td>
</tr>
</table>
</s:form>
</body>
</html>
Detail.jsp
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="/struts-dojo-tags" prefix="sx"%>
<table border="0" width=100%>
<s:if test="branchList != null">
<tr><td><s:select name="branch" list="branchList" label="Branch"></s:select></td></tr></s:if>
<s:if test="semList != null">
<tr><td><s:select name="sem" list="semList" label="Semester" /></td></tr></s:if>
</table>
FirstList.java
package bharat;
public class FirstList extends ActionSupport {
private String course;
private Map<Integer,Integer> semList=null;
private Map<String, String> branchList=null;
public String execute() throws Exception
{
populateTwo(getCourse());
return SUCCESS;
}
public void populateTwo(String id1)
{
// Get null value for id1
System.out.println (id1);
if(id1!=null&&!id1.equals(""))
{
semList=new HashMap<Integer,Integer>();
branchList=new HashMap<String,String>();
if (id1.equalsIgnoreCase("B.Tech.")||id1.equalsIgnoreCase("M.Tech.")) {
branchList.put("CSE","CSE");
branchList.put("ECE","ECE");
branchList.put("MAE","MAE");
branchList.put("CHE","CHE");
branchList.put("CVE","CVE");
branchList.put("IT","IT");
} else if (id1.equalsIgnoreCase("MCA")) {
branchList.put("CS","CS");
branchList.put("EC","EC");
branchList.put("MA","MA");
branchList.put("CIV","CIV");
branchList.put("IT","IT");
}
else{branchList.put("None","None");}
if (id1.equalsIgnoreCase("B.Tech.")||id1.equalsIgnoreCase("Bio.Tech.")) {
semList.put(1,1);
semList.put(2,2);
semList.put(3,3);
semList.put(4,4);
semList.put(5,5);
semList.put(6,6);
semList.put(7,7);
semList.put(8,8);
setSemList(semList);
} else if (id1.equalsIgnoreCase("M.Tech.")) {
semList.put(1,1);
semList.put(2,2);
semList.put(3,3);
semList.put(4,4);
} else {
semList.put(1,1);
semList.put(2,2);
semList.put(3,3);
semList.put(4,4);
semList.put(5,5);
semList.put(6,6);
}
}
}
public String getCourse() {
return course;
}
public void setCourse(String course) {
this.course = course;
}
public Map<Integer,Integer> getSemList() {
return (this.semList);
}
public void setSemList(Map<Integer,Integer> semList) {
this.semList = semList;
}
public void setBranchList(Map<String, String> branchList) {
this.branchList = branchList;
}
public Map<String, String> getBranchList() {
return branchList;
}
}
Struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="hibernate-default">
...
<action name="StudentRegister" class="bharat.RegistrationAction">
<interceptor-ref name="defaultStackHibernate">
<param name="fileUpload.allowedTypes">image/png,image/gif,image/jpeg</param>
</interceptor-ref>
<result name="input">/jsp/StudentRegistration.jsp</result>
<result name="success">/jsp/success2.jsp</result>
</action>
**<action name="linkStudentRegister" method="populateOne" class="bharat.RegistrationAction">
<result name="success">/jsp/StudentRegistration.jsp</result>
</action>
<action name="secload" class="bharat.FirstList">
<result name="success">/jsp/Detail.jsp</result>
</action>**
</package>
</struts>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>CourseRegistrationModule</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
RegistrationAction.java
package bharat;
public class RegistrationAction extends ActionSupport implements ModelDriven<Register>,ServletRequestAware {
private Register register = new Register();
private RegisterDAO registerDAO = new RegisterDAOImpl();
private HttpServletRequest servletRequest;
private Map<String,String> courseList= null;
public String populateOne()
{
System.out.println ("populateone");
courseList=new HashMap<String,String>();
courseList.put("B.Tech.","B.Tech.");
courseList.put("M.Tech.","M.Tech.");
courseList.put("MCA","MCA");
courseList.put("Bio.Tech.","Bio.Tech.");
return SUCCESS;
}
public Map<String,String> getCourseList() {
return (this.courseList);
}
public void setCourseList(Map<String,String> courseList) {
this.courseList = courseList;
}
@Override
public Register getModel() {
//TODO
return register;
}
View Answers
Related Tutorials/Questions & Answers:
getting null value in action from ajax callgetting null value in
action from ajax call
Getting null value from ajax call in
action (FirstList.java)... first list is loading correctly. Need..." name="form1"
action="StudentRegister" method="post" enctype="multipart/form-data
getting null value in action from ajax callgetting null value in
action from ajax call
Getting null value from ajax call in
action (FirstList.java)... first list is loading correctly. Need..." name="form1"
action="StudentRegister" method="post" enctype="multipart/form-data
Advertisements
getting null value in action from ajax callgetting null value in
action from ajax call
Getting null value from ajax call in
action (FirstList.java)... first list is loading correctly. Need..." name="form1"
action="StudentRegister" method="post" enctype="multipart/form-data
database call from javaScript - Ajaxdatabase
call from javaScript Dear All, In my project i have one... name. and i have to do this in javascript.How do i
call database query ,if suppose i have selected two building
from text area,i have to finish
https call in AJAX - Ajaxhttps
call in AJAX Hi,
I am trying to
call a https URL in my
AJAX script which is in my JSP. But it is not
getting the reponse
from the url i.../jsp/popup-window-using-
ajax-in-jsp.shtml
Hope that it will be helpful for you
Why you are not getting value from your data science?Why you are not
getting value from your data science? Hi,
I am... for
the tutorials to learn:
Why you are not
getting value from your data science?
Try...;Why you are not
getting value from your data science?". Also tell me which
How to get more than one value from ajaxHow to get more than one
value from ajax I have multiple select list box in php. i filled the
value using
ajax. how to get different
value to fill the same list box
Ex.
option
value as id
(adsbygoogle
ajax+options is null or not an Objectajax+options is
null or not an Object HI
i have developed a simple
ajax application contains two drop down lists and and one search button when i seleted a mangername
from the popuated dropdwon list its dispalyed all
what is an ajax call?what is an
ajax call? can u please explain the correct usage of an
ajax call in jsps and java script.
hi friend,
Ajax is new technologies for the development of web application.
Ajax is known as Asynchronous
Nested Ajax--not getting outputNested
Ajax--not
getting output Hi everyone...
I have two.jsp page
from that , with the help of
ajax i have called three.jsp.
So, i have used DIV... time running...when i run One.jsp , with the help of
ajax when i
call two.jsp.
getting db in action classgetting db in
action class hi,
Am usin struts in ma application...
n i need to interact with the db ..
so i used.. getDataSource(request)
but it gives me an error..
java.lang.NoSuchMethodError: LoginAction.getDataSource(Ljavax
what is an ajax call?what is an
ajax call? can u please explain the correct usage of an
ajax call in jsps and java script
Output of null value main(String [] args){
String str=
null;
System.out.println(str);
}
}
Output
value
Null
Description:- In the given example... a String variable and initialized it with
null value mysql query for null value mysql query for
null value What mysql query for
null value i need... {
//echo message
}
To check if the object contain any
value or not ..just compare it with zero. If the
value for object is greater than zero display
Error in checking null value in stringError in checking
null value in string Error in checking
null value in string
Hi am
getting Exception : java.lang.NullPointerException in the following code:
String registerno=
null;
registerno=request.getParameter("registerno
Getting garbage valueGetting garbage value Thank You Sir for helping me out
from...
from the link gets some garbage
value whenever I'm using some particular set of
value like
from 0010 to 0757. After that
from 0758 to 2400 every
value returns
Getting garbage valueGetting garbage value Thank You Sir for helping me out
from...
from the link gets some garbage
value whenever I'm using some particular set of
value like
from 0010 to 0757. After that
from 0758 to 2400 every
value returns
Getting Null pointer Exception in the jsp pageGetting Null pointer Exception in the jsp page I have developed this jsp page to store the data in database.While storing the
value of check box in database I am
getting null pointer exception in the following code
Getting Null pointer Exception in the jsp pageGetting Null pointer Exception in the jsp page I have developed this jsp page to store the data in database.While storing the
value of check box in database I am
getting null pointer exception in the following code
Getting Null pointer Exception in the jsp pageGetting Null pointer Exception in the jsp page I have developed this jsp page to store the data in database.While storing the
value of check box in database I am
getting null pointer exception in the following code
Getting Null pointer Exception in the jsp pageGetting Null pointer Exception in the jsp page I have developed this jsp page to store the data in database.While storing the
value of check box in database I am
getting null pointer exception in the following code
Struts2.2.1 Action Tag ExampleStruts2.2.1
Action Tag Example
The
Action tag is used to
call action class directly
from a JSP page.
We can
call action directly by specifying... the results
from the
Action.
The following Example will shows how to implement
Getting garbage valueGetting garbage value Thanks for the reply. Its works well, but whenever I'm using numeric
value from 0010 to 0757 it is returning some garbage
value. I dont have the idea what is going wrong. Please give me some idea to solve
getting values from dropdown listgetting values
from dropdown list I am having a dropdown list which... to the
action.
My
action is
getting called however, i am not sure how to pass the selected
value to the
action. Please can any one please help me out
RADIO FROM JSP TO ACTION.RADIO
FROM JSP TO
ACTION. Hi frds,
how to get the selected multiple radio button values
from jsp to
action radio button value on edit action...Problem 'm facing is on edit
action 'm not retrieving radio button
value..i have...radio button
value on edit action This is my edit.jsp code...In my...;
}
}
function toggle(
value)
{
if(
value Why string is storing null value - IoCWhy string is storing
null value I am reading lines
from a file and then splitting it with " " as the criteria
If line has first element
null... it is also storing
null value in temp. WHY so
call from java - JavaMailcall from java Hi,
how i will
call servlet
from java..
plz its... the java.net package to
call a servlet
from the java code...) session.getAttribute("MySessionVariable");
if (param !=
null change value - Ajaxchange value hello buddy.........please help me
i have a drop down box, i have to change my text box
value acording to that drop down option.........(where all i need to change to use
ajax in my application
getting files from VSSgetting files
from VSS I am not able to get the files
from VSS.I am using following code.
and just let me know is localpath attribute is for our local project path?
I am
getting the problem in this line failed
Java-call by value - Java BeginnersJava-
call by value Why java is called strictly "
call by
value" and not "
call by reference" ?Please explain with example? Hi Friend... object references by
value. This is because two copies of the same reference refer
Option onclick am not getting the value .. Option onclick am not
getting the
value .. function get_val( tot_val )
{
document.getElementById('TextBox1').
value = tot_val;
}
<..._val( tot_val )
{
document.getElementById('TextBox1').
value = tot_val
Getting Textbox data from databaseGetting Textbox data
from database When i m trying to get data in textbox as readonly
from database i m
getting following error.and my code is shown...");
ResultSet rs=
null;
Statement stmt=
null;
try{
Class.forName
Getting Textbox data from databaseGetting Textbox data
from database When i m trying to get data in textbox as readonly
from database i m
getting following error.and my code is shown... an internal error () that prevented it
from fulfilling this request.
exception
Call an array from multiple functionsCall an array
from multiple functions I am having two methods in this method i am
getting array values
from another class.
i create same array name for accessing the method values(array) but it will access only one method values