my dog learned polymorphism*
The moose likes JSP and the fly likes Jquery request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Jquery request" Watch "Jquery request" New topic
Author

Jquery request

jagannadha reddy
Greenhorn

Joined: Jul 02, 2010
Posts: 14
Hi,

I need to send request to Bean which will get data from database and send to the same jsp and need to display this data in same jsp.
For this by using jquery sent request to Bean and getting data back to jsp but this data is not displaying. How i can resolve this? Please help me.... Very urgent.

For your reference posting my jsp code also.

<%
/**
* CrystalReportBeanList.jsp
* Copyright (c) 2003-2004 Emagia Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Emagia
* Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Emagia.
*
* EMAGIA MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. EMAGIA SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*
*
*@author Jagan,Maruthi Jaganmohan Guda
*
*
*
*
**/
%>
<%@ taglib uri="http://jakarta.apache.org/taglibs/i18n-1.0" prefix="i18n" %>
<%@ taglib uri="http://taglib.emagia.com/taglibs/emagia" prefix="emagia" %>

<%@ page language="java" %>
<%@ page import="emagia.beans.*"%>
<%@ page import="emagia.customer.beans.*"%>
<%@ page import="emagia.bizobjects.User"%>
<%@ page import="emagia.bizobjects.Report"%>
<%@ page import="emagia.bizobjects.ReportGroup"%>
<%@ page import="emagia.crystalreports.beans.CrystalReportBeanList"%>
<%@ page import="emagia.crystalreports.beans.CrystalReportDefinitionBean"%>
<%@ page import="emagia.utils.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.math.BigDecimal"%>
<%@ page import="emagia.utils.EmagiaProperty"%>
<%@ page import="emagia.utils.Trace"%>
<%@ page import="emagia.admin.beans.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="emagia.bizobjects.*"%>
<%@ page import="java.lang.reflect.*"%>
<%@ page import="emagia.ejb.*"%>
<%@ page import="emagia.bizobjects.beans.*"%>
<%@ page import="emagia.utils.ConditionConstants"%>
<%@ page import="java.text.*"%>
<%
/**
*
* Get the Presentation object from session with key "PRESENTATION".
* Get the model(GroupReportBeanList) from the above presentation object.
* Get the list of groups and reports from the above array list.
* Get the User object from the session with key "USERINFO".
*
*/
%>
<%
String SERVER_CONTEXT= "";
SERVER_CONTEXT = (String)request.getContextPath()+"/";
%>

<%
Presentation presentation = (Presentation)session.getAttribute("PRESENTATION");
String dateFormat = (String)session.getAttribute("DATE_FORMAT");
CrystalReportBeanList crystalReportBeanList = (CrystalReportBeanList)presentation.getModel();
ArrayList reportBeanList = crystalReportBeanList.getBeanList();

HashMap ghm=(HashMap)reportBeanList.remove(reportBeanList.size()-1);
BigDecimal iUserId = new BigDecimal("0");
String strName = "";
String strFullName = "";
String strEmailId = "";
String strURL="";
String strAssociatedCompanies = "";
String rv = "";

//added by Jagan for jquery changes
String fp=null;
String rn=null;
String srn=null;
String paramName = null;
String na = null;
String defaultval = null;
String paramDesc = null;
int jq = 0;
//end by Jagan

User user = (User)session.getAttribute("USERINFO");
iUserId = new BigDecimal(Utilities.removePortalClient(user.getId()));
strName = user.getName()==null?"":user.getName();
strFullName = user.getRepName()==null?"":user.getRepName();
strEmailId = user.getEmailId()==null?"":user.getEmailId();
strURL = SERVER_CONTEXT+"servlet/FrontController";

String portalClient = user.getPortalClient();
String strServletIP = EmagiaProperty.getValue("CRYSTAL_REPORTS_URL",portalClient);

// Based on the template name get the properties from the HashMap defined in Front Controller
HashMap hmpTemplateProperties = null;
String strTemplate = (String) session.getAttribute("TEMPLATE");
hmpTemplateProperties = Utilities.getTemplateProperties(strTemplate);

%>
<%
Locale localeObj = (Locale)session.getAttribute("userLocale");
ResourceBundle bundle = emagia.utils.Utilities.getResourceBundle(localeObj,"org.apache.taglibs.i18n.i18n-emagia");
%>

<FORM name="PRESENTATION" method="POST" action="">
<input type="hidden" name="REQUEST_TYPE" value="">
<input type="hidden" name="BEAN_NAME" value="">
<input type="hidden" name="BEAN_COMMAND" value="">
<input type="hidden" name="BEAN_CONDITION" value="">
<input type="hidden" name="BEAN_ID" value="">

<table width="100%" border="0"cellPadding="0" cellSpacing="0" class="screenHead">
<tr>
<td width="50%" class="tablehead">
<a href="Javascript:CenteredWindow('<%=hmpTemplateProperties.get("MAIN_PATH")%>/Dynamic_Reports.htm#DynamicRepGroupBy ','<%=hmpTemplateProperties.get("HELPWND_NAME")%>','<%=hmpTemplateProperties.get("HELP_WIDTH")%>','<%=hmpTemplateProperties.get("HELP_HEIGHT")%>','yes');" onMouseOver="MM_displayStatusMsg('<%=bundle.getString("ECIM")%>');return document.MM_returnValue">
<img border="0" align="absMiddle" src="<%=hmpTemplateProperties.get("HELP_ICON")%>"></a> <%=bundle.getString("GROUP_REPORT_LIST_TITLE")%>
</td>
</tr>
</table>
<table cellSpacing="0" cellPadding="0" border="0" width="100%">
<br>
<tr>
<td>
</td>
</tr>
</table>
<table cellSpacing="0" cellPadding="0" border="0" width="98%">
<tr>

<td><img border="0" src="<%=SERVER_CONTEXT%>web/images/dot.gif" width="1" height="18">


<%
try
{
if(reportBeanList!=null && reportBeanList.size()>0){
for(int iGroupCount=0;iGroupCount<reportBeanList.size();iGroupCount++){
String groupName = (String)reportBeanList.get(iGroupCount);
ArrayList al=(ArrayList)ghm.get(groupName);
%>
<table>
<tr>
<th style="text-align:left"><%=Utilities.singleQuoteDoubleQuote(Utilities.newlineCharReplaceWithCarat(groupName))%>
</th></tr>
</table>
<table align="center" cellSpacing="0" cellPadding="0" border="0" width="100%" class="dataTable" borderColor="#cccccc">
<tr><th style="text-align:left">
        Report Name
                                       
                                        
Report Description
</th></tr>
</table>
<table align="center" cellSpacing="0" cellPadding="0" border="0" width="100%">
<%
for(int i=0;i<al.size();i++)
{
ArrayList arrReports = (ArrayList)al.get(i);
%>
<tr bgColor="#FFFFFF" ONMOUSEOVER="bgColor='#EFEFEF'" ONMOUSEOUT="bgColor='#FFFFFF'">
<td height=18 align="left" width="5%" valign="middle"></td>
<td height=18 align="left" width="45%" valign="middle">
<a class="jql" href="#" onclick="DoAction('<%=arrReports.get(0)%>');">+</a>
<a href="javascript:viewReport('<%=arrReports.get(0)%>')" onMouseOver="MM_displayStatusMsg('<%=bundle.getString("ECIM")%>');return document.MM_returnValue"><%=Utilities.singleQuoteDoubleQuote(Utilities.newlineCharReplaceWithCarat((String)arrReports.get(1)))%></a>
<%rv=arrReports.get(0).toString();%>
</td>

<%
String strArrText1[]=Utilities.convertTexttoToolTip((String)arrReports.get(2));
if(strArrText1[0].trim().length()>0){
%>
<td width="50%" align="left" NOWRAP height=18 valign="middle"><a><span ONMOUSEOVER="showToolTipLayer('<%= strArrText1[1]%>','')" ONMOUSEOUT="htm()"><%= strArrText1[0]%></span></a></td>
<%
}
%>

</tr>
<%ArrayList preportBeanList = crystalReportBeanList.getParameters();
if(preportBeanList!=null && preportBeanList.size()>0){
if(jq==0){
System.out.println("Jagan jq: "+jq);
%>
<tr><td><div id="servletReport" class = "sr" style="position:relative;">
<%
System.out.println("Jagan preportBeanList size in jsp: "+preportBeanList.size());
ArrayList defl = (ArrayList)preportBeanList.remove(preportBeanList.size()-1);
ArrayList desAl = (ArrayList)preportBeanList.remove(preportBeanList.size()-1);
String subreport = (String)preportBeanList.remove(preportBeanList.size()-1);
String reportname = (String)preportBeanList.remove(preportBeanList.size()-1);
ArrayList valueList=(ArrayList)preportBeanList.remove(preportBeanList.size()-1);
ArrayList lovList=(ArrayList)preportBeanList.remove(preportBeanList.size()-1);
ArrayList dal=(ArrayList)preportBeanList.remove(preportBeanList.size()-1);
%>
<input type="hidden" name="REPORT_ID" value="<%=crystalReportBeanList.getId()%>">
<input type="hidden" name="MAIN_REPORT_NAME" value="<%=reportname%>">
<input type="hidden" name="SUB_REPORT_NAME" value="<%=subreport%>">
<fieldset>
<legend class="legendHead">
<img border="0" align="absMiddle" src="/ee/web/images/colnote.gif">
Enter Parameters
</legend>
<table cellSpacing="0" cellPadding="0" border="0" width="100%">
<%
try
{
for(int ij=0;ij<preportBeanList.size();ij++)
{
%>
<tr bgColor="#FFFFFF" ONMOUSEOVER="bgColor='#EFEFEF'" ONMOUSEOUT="bgColor='#FFFFFF'">
<% System.out.println("defl size"+defl.size());
paramName=(String)preportBeanList.get(ij);
System.out.println("Before Formatting : "+paramName);
paramName = paramName.replaceAll(" ","_");
paramName = paramName.replaceAll("@","AT");
na=paramName.substring(0,4);
System.out.println("Before Formatting : "+na);
if(na.startsWith("AT")) na=paramName.substring(2,6);
paramDesc=(String)desAl.get(ij);
defaultval=(String)defl.get(ij);
if(defaultval!=null){
System.out.println("Default value is"+defaultval);
%>
<input type="hidden" name="CRQ<%=paramName%>" value="<%=defaultval%>">
<%
}
if(defaultval==null){
System.out.println("Jagan defaultval: "+defaultval);
System.out.println("Jagan na: "+na);
if(na.equalsIgnoreCase("user")){
fp = paramName;

if(na.startsWith("AT"))
fp="AT"+paramName;
System.out.println("Jagan fp: "+fp);
session.setAttribute("fpn",fp);
%>
<input type="hidden" name="pn" value="<%=fp%>">
<%}

if(!(na.equalsIgnoreCase("user"))){%>
<td><%=paramDesc%></td>
<%if(lovList.get(ij).equals("Y")){
System.out.println("Parameter Name "+paramName);
System.out.println("Parameter Prompt "+paramDesc);
%>
<td>
<input TYPE="radio" NAME="entervalue<%=ij%>" VALUE="true" checked onClick="javascript:enableField(this,document.PRESENTATION.CR<%=paramName%>,document.PRESENTATION.CRSELECTAT<%=paramName%>)">

<input type="text" name="CR<%=paramName%>">
<input TYPE="radio" NAME="entervalue<%=ij%>" VALUE="false" onClick="javascript:enableField(this,document.PRESENTATION.CRSELECT<%=paramName%>,document.PRESENTATION.CR<%=paramName%>)">

<select name="CRSELECT<%=paramName%>" disabled>
<%
System.out.println("Jagan: "+paramName);
ArrayList arrTemp = (ArrayList) valueList.get(ij);
for(int j=0;j<arrTemp.size();j++){
%>
<option value="<%=arrTemp.get(j)%>"><%=arrTemp.get(j)%></option>
<%}
%>
</select>
<%
}
else{
%>
<td>      <input type="text" name="CR<%=paramName%>" >
<%

String val=(String)dal.get(ij);
if(val.equalsIgnoreCase("Date"))
{
%>
<a href="javascript:show_calendar('PRESENTATION.CR<%=paramName%>',null,null,'<%=(String)session.getAttribute("DATE_FORMAT")%>');" onmouseover="window.status='Emagia Cash Inflow Manager';return true;" onmouseout="window.status='';return true;">
<img src="<%=SERVER_CONTEXT%>web/images/calender.gif" border="0" alt="calendar"></a>
<%}
}
}
}%>
</td>
</tr>
<%
jq=1;
}
preportBeanList = null;
}
catch(Exception e){
e.printStackTrace();}
session.setAttribute("pn",fp);
session.setAttribute("rn",reportname);
%>
</table>
<br><br>
<center><input type="button" onClick="javascritp:submitForm();" class="formButton" value="View Report"></center>
</fieldset>
</div></td></tr>
<%}
}
%>
<%

}
%>

</table>
<br>
<%
}//end of for loop
%>

</td>
<%
} else{
%>
No Reports Available</td>
<%
}
}
catch(Exception e){
e.printStackTrace();}
%>

</tr>
</table>

</FORM>

<script type="text/javascript" src="<%=SERVER_CONTEXT%>web/js/jquery.js"></script>
<script language="javascript" src="/ee/web/js/calender.js"></script>
<SCRIPT type="text/javascript" language="javascript1.2">

// ---------------------- LAYERS RELATED CODE ------------------------------------------------
applyCssFilter(); // This function has to be called to set the Layer filters of the Notes Layer

function showToolTipLayer(strNotes,strTitle){
Text[0]=[strTitle,strNotes];
stm(Text[0],Style[1]);
}

function viewReport(reportValue){
var userId = "<%=iUserId%>";
var userName = "<%=strName%>";
var userFullName = "<%=strFullName%>";
var userEmailId = "<%=strEmailId%>";
url = "<%=SERVER_CONTEXT%>servlet/FrontController?dummy="+(new Date()).getTime()+"&BEAN_ID="+reportValue+"&BEAN_COMMAND=VIEW_REPORT&REPORT=View&REQUEST_TYPE=BEAN&BEAN_NAME=crystalreports.CrystalReportDefinition&BEAN_JSP_NAME=/crystalreports/jsp/CrystalReportDefinitionBean.jsp";
CenteredWindow(url,'Params','800','400','yes');
}

function DoAction(id)
{
alert(id);
$.ajax({
type: "POST",
url: "<%=SERVER_CONTEXT%>servlet/FrontController?dummy="+(new Date()).getTime()+"&BEAN_ID="+id+"&BEAN_COMMAND=LOAD_ALL&REPORT=View&REQUEST_TYPE=BEAN_LIST&BEAN_NAME=crystalreports.CrystalReport&BEAN_JSP_NAME=/crystalreports/jsp/CrystalReportBeanList.jsp",
data: "BEAN_ID=" + id,
success: function(msg){
alert(id);

}
});
}

$(document).ready(function(){
$(".sr").hide();
$(".jql").click(function(event){

//$("#jReport").load("/ #servletReport");
$(".sr").show(2000);
/*var refreshId = setInterval(function() {
$("#servletReport").show(2000);
}, 9000);*/
//$(".sr").html($(this).html());
});
});

/*function submitForm(){

document.PRESENTATION.submit();
}*/

function enableField(fldobj,objenb,objdis)
{
objenb.disabled=false;
objdis.disabled=true;
}
function submitForm()
{
var un = "<%=strName%>";
var p = "<%=(String)session.getAttribute("fpn")%>";
var url = "<%=strServletIP%>/crystalreports/CRLoadingJunction.jsp?userName=<%=strName%>&UserDate=<%=(String)session.getAttribute("DATE_FORMAT")%>&pn=<%=(String)session.getAttribute("fpn")%>";
alert(un);
alert(p);

if(valid())
{
//document.PRESENTATION.submit();
alert(un);
CenteredWindow(url,'Params','800','400','yes');
}
}
function valid()
{
for(var i=0;i<document.PRESENTATION.elements.length;i++){
if (document.PRESENTATION.elements[i].type=="text" && document.PRESENTATION.elements[i].disabled==false) {
if(document.PRESENTATION.elements[i].value==""){
var s = document.PRESENTATION.elements[i].name;
s=s.substring(2,s.length);
if(s.indexOf("user") > -1){
}
else{
alert("Please Enter Value for "+s);
document.PRESENTATION.elements[i].focus();
}
return false;
}
}
}

return true;
}

</script>
 
Consider Paul's rocket mass heater.
 
subject: Jquery request
 
Similar Threads
dynamic table creation problem calling onchange
Unable to compile class for JSP
can any on resolve error javax.servlet cannot be resolved to a type
about checking values between rows with dynamic table created using java script
spaces while populating using s:iterator