getting null value in action from ajax call

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 call
getting 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 call
getting 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 call
getting 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 my class when using t:inputFileUpload
getting null value in my class when using t:inputFileUpload  getting null value in my class when using t:inputFileUpload
database call from javaScript - Ajax
database 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
getting null value in my class when using t:inputFileUpload
getting null value in my class when using t:inputFileUpload  getting null value in my class when using t:inputFileUpload i have implemented all... changes in web.xml also still getting null value when i access in my bean Thanking
Getting environment variable value from java
Getting environment variable value from java  Getting environment variable value from java
getting unique value from java.util.random - Java Beginners
getting unique value from java.util.random  i am doing a shopping... for that i used java.util.random to get random productid from product table, but the value which i am getting contains duplicate values and it is not unique, my
https call in AJAX - Ajax
https 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
How to pass value from dijit.Tree to dijit.MenuItem - Ajax
How to pass value from dijit.Tree to dijit.MenuItem  Hi Friends, I... of 'Test' I want to show the value of that Node( which is comming from TreeNode... node whicl will apper on right click. What I have already done. From my server
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 ajax
How 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 Object
ajax+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 output
Nested 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 class
getting 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 string
Error 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 value
Getting 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 value
Getting 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 page
Getting 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 page
Getting 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 page
Getting 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 page
Getting 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 Example
Struts2.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 value
Getting 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 list
getting 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
Pass value of rasio button from jsp page to action class(not conventional problem)
Pass value of rasio button from jsp page to action class(not conventional...; </table> <s:submit value="Delete" action="deleteSchedule...;table border="1"> <tbody> <s:iterator value
javascript call action class method instruts
javascript call action class method instruts  in struts2 onchange event call a method in Actionclass with selected value as parameter how can i do
<%=request.getHeader("referer")%>,getting null in jsp - JSP-Servlet
,getting null in jsp  Hi, I am getting null in in jsp.Could you help on this regards. Thanks Ajay   Hi friend, Code to help in solving the problem : Thanks
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
ModuleNotFoundError: No module named 'djangocms-call-to-action'
ModuleNotFoundError: No module named 'djangocms-call-to-action'  Hi...: No module named 'djangocms-call-to-action' How to remove the ModuleNotFoundError: No module named 'djangocms-call-to-action' error? Thanks  
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 - IoC
Why 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 - JavaMail
call 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
getting coords from an image.
getting coords from an image.  how to get coordinates dynamically(in run time) from an image?? pls help me
change value - Ajax
change 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 VSS
getting 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
receiving null value in back bean by the jsf page
receiving null value in back bean by the jsf page  i have done above things but i m receiving null value in back bean by the jsf page plz tell me solution as soon as possible
Java-call by value - Java Beginners
Java-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 database
Getting 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 message from the server using RPC( Remote Procedure Call )
Getting message from the server using RPC( Remote Procedure Call... describes the procedure of retrieving message from the server via RPC. The steps involved in geting message from the server are described below:- Step1:-Right
Getting Textbox data from database
Getting 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
Spring Null value, Set null value in Springs configuration file
Spring Null value, Set null value in Springs configuration file In this example you will see how to set null value in the Spring configuration file... this application it will display output as shown below:     null
Call an array from multiple functions
Call 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
Sending error code to access log of tomcat server from Action class
Sending error code to access log of tomcat server from Action class  How to send an error code (500) to access log file when we get null value in an if condition in Action class? Is anyone aware of this! Thanks
write a program to demonstrate call by value and call by reference.(pass objects as parameters)
write a program to demonstrate call by value and call by reference.(pass objects as parameters)  write a program to demonstrate call by value and call by reference.(pass objects as parameters

Ads