Home Answers Viewqa Ajax getting null value in action from ajax call

 
 


BHARAT GUPTA
getting null value in action from ajax call
0 Answer(s)      11 months ago
Posted in : Ajax

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 Pages:
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
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
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
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
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 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
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
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 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
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
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
check null exception java
when we call or perform some action on the object or value when it null (contains no value). Whenever you'll perform any action on null objects the JVM throw... if the object is null or assigned some value to it before performing action
AJAX
ajax. My table is CREATE TABLE HTNEWMETER ( ID NUMBER (10) NOT NULL, METERNO VARCHAR2 (30) NOT NULL, PONO VARCHAR2 (30) NOT NULL, STORENAME VARCHAR2 (20... from today.e.g-If am checking on 11th Jan 2011,it should whose(11kv) testing
ajax
; String seconds=null;//modifying from long...ajax  I am facing following problem, I am using ajax to get..., am calling another jsp(two.jsp) which is responsible to get the new data from
Ajax with BIRT - Ajax
to call my BIRT report from my jsp on a button Click. I have tried some code. But I am getting a blank page. I have been searching for it from quit a some time but I...; //} // else { // alert("Error during AJAX call. Please try again
ajax doubdt
of ajax that will display the database values in the textboxes by getting the id...ajax doubdt  function getentityshortname(val) { alert("entered...); //document.forms[0].action=url; //document.forms[0].submit
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
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
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
ajax problem - Ajax
ajax problem   var xmlObj = new ActiveXObject...]); } } } xmlObj.send(null); } On Select change data of another Select Select One india UK US AUS In the above code I am not getting
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
comparison with null - Framework
comparison with null  I am having one textfield, from which I am getting text using getText() method. Now I want to compare this value with null (i.e. to check whether the entered value is null or not) How should I check
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
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
problem getting servlet:xmlHTTP.status=404 - Ajax
problem getting servlet:xmlHTTP.status=404   hi, ihave a text field in which i type some words and get related response from db via XMLHTTP request...("search").value; var url = contextPath +"packageName/FolderName
Forgot Password Action,Struts Forgot Password Action class
password action, if the value matches the action sends an email of user name...+="\n \n Thanks"; message+="\n \n \n Regards"; // getting from... Forgot Password Action     
ajax for sturts - Ajax
ajax for sturts  Hi, I am trying to connect to the struts action class using ajax but I am getting error(not able to call actionclass),but when i use servlets I can call easily. how to solv it? plz help me... thanks
Ajax - Ajax
Ajax  I want to get data from database on change event of combobox/list. Suppose I select India through list box then I get all related data from...; } function showEmp(emp_value) { if(document.getElementById("emp_id").value
NUll POINTER EXCEPTION
of code i m getting null pointer Exception. can some one please explain what...NUll POINTER EXCEPTION  public void doGet(HttpServletRequest request...;form method="get" action="../CalculateSalary"> BASIC: <input type="text
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
org.apache.jasper.JasperException: java.lang.NumberFormatException: null
. But I'm getting "org.apache.jasper.JasperException: java.lang.NumberFormatException: null" exception. Also "The server encountered an internal error () that prevented it from fulfilling this request" error. I hope you will help me. Here
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
hi - Ajax
, IOException{ String value = req.getParameter("country"); String dbQuery1 = "Select country_ID FROM TB_countries WHERE country_name='" + value + "'"; String... me know what kind of error u getting in Ajax. if possible come online through
Call servlet from javascript - JSP-Servlet
Call servlet from javascript  Hi in my application i have jsp... screen when the user clicks submit button i have to pass this column values from... charactars the servlet url is not propelry formed and servlet is not getting invoked
To display suggestions in a text box - Ajax
. 2)On this text box call a function onKeyUp event using Ajax. 3)Pass the value of Keyword to process page Using Ajax. 4)After getting the response you display...:'A'), the names that starts from 'A' have to display in the text box
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
returning a value from Threads
returning a value from Threads  Hello I have worker pattern that uses ExecutorService to schedule Thread execution but getting stuck at some point when returning a value using Future.I have code snippet below: ExecutorService
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
Action and AbstractAction
the status of this Action.  act.putValue(String key, Object value... the desired component from the Action, then modify it. JMenuItem exitItem = new JMenuItem... to implement action listeners that can be shared and coordinated. Actions can
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 frame - Java Beginners
static JButton defaultButton = null; //constants for action commands...call frame   dear java, I want to ask something about call frame...) { Logger.getLogger("global").log(Level.SEVERE, null, ex
ajax
ajax  HI, In my application using ajax if i type a managername... in a dropdown from database and when i select the empname in dropdwon list and when i click on search button it should display the employee details from database pls help
ajax
;This very simple Ajax Example retrieves the current date and time from server...ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>
ajax
;This very simple Ajax Example retrieves the current date and time from server...ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>