Subhradip Podder

Ranch Hand
+ Follow
since Aug 27, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Subhradip Podder

I tried it.... but same thingh will happen
13 years ago
Hi All,

I am new in struts.. i'm trying to check validation on login form on client side,but i'm failure to do this again and again.The warning massege does not come on browser.Can any body help me....

Following is my code:-

struts-config.xml

<message-resources parameter="ApplicationResources" null="false" />


<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>

validation.xml

<form-validation>
<formset>
<form name="loginForm">
<field property="username" depends="required">
<arg0 key="prompt.username"/>
</field>
<field property="password" depends="required">
<arg0 key="prompt.password"/>
</field>
</form>
</formset>
</form-validation>

validator-rules.xml

<form-validation>

<global>

<validator name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>

</global>
</form-validation>

ApplicationResources.properties

prompt.username=Enter Name:
prompt.password=Enter Password:

login.jsp

<body>
<html:img align="left" border="0" height="37px" width="191px" page="/image/iotl logo.jpg" />
<html:link page="/jsp/registration.jsp"><br><br>
<hr width="100%" size="3">New User</html:link>
<center>
<html:form action="/login" method="post" focus="username" onsubmit="return validateloginForm(this);">

<html:errors />
<pre>
Login Page
</pre>
<table border="0" width="238" height="60">
<tr>
<td>User Id:</td>
<td><html:text property="username" /></td>
</tr>
<tr>
<td>Password:</td>
<td><html assword property="password" /></td>
</tr>
</table>
<table width="101" height="32">
<tr>
<td colspan="2" align="center"><html:submit /></td>
</tr>
</table>

<!-- Begin Validator Javascript Function-->
<html:javascript formName="loginForm" />
<!-- End of Validator Javascript Function-->

</html:form>
</center>
</body>
13 years ago
Hi All,

How can I write a validation.xml file in myeclipse 5.1 version . Because when I select ADD STRUTS CAPABILITIES to my web project by defaultly it shows struts-config.xml, validation-rules.xml, html.dtd and soo on . But it was not showing the VALIDATION.XML file in the project explorer ....
How can I write or How can I configure the validation.xml in MYECLIPSE 6.0 version

please help me.
13 years ago
Hi All,

I have facing a problem to develop a code, that is -----
Cannot find message resources under key org.apache.struts.action.MESSAGE

Also i used struts 1.2 and my web.xml and struts-config.xml are following---

web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>com.iotl.struts.ApplicationResources</param-value>
</init-param>

<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
.................


<struts-config>
<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<set-property property="url" value="jdbc racle:thin:@172.16.90.139:1531 ROD"/>
<set-property property="username" value="apps"/>
<set-property property="password" value="apps"/>
</data-source>
</data-sources>

<form-beans >
<form-bean name="loginForm"
type="com.iotl.struts.form.LoginForm" />

</form-beans>

<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="loginForm"
input="/login.jsp"
name="loginForm"
path="/login"
scope="request"
validate="true"
type="com.iotl.struts.action.LoginAction">
<forward name="success" path="/jsp/menu.jsp" />
<forward name="failure" path="/jsp/failure.jsp" />
</action>


</action-mappings>


Please Please help me.......
13 years ago
Hi all,

I am written a <data-sources> code in struts-config.xml. Also i written a LoginAction class to access the database.But i'm unable to connect database,
given a error like java.lang.NullPointerException
com.iotl.struts.action.LoginAction.execute(LoginAction.java:55)
org.apache.struts.action.RequestProcessor.processActionPerform (RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)


Can anybody help me to tell my error.

following is my code:-

struts-config.xml

<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<set-property property="url" value="jdbc racle:thin:@172.16.90.139:1531 ROD"/>
<set-property property="username" value="apps"/>
<set-property property="password" value="apps"/>
</data-source>
</data-sources>


LoginAction.java:-

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
LoginForm loginForm = (LoginForm) form;// TODO Auto-generated method stub
javax.sql.DataSource dataSource = null;
java.sql.Connection myConnection;
String username = loginForm.getUsername();
String password = loginForm.getPassword();

try{
ServletContext context = servlet.getServletContext();
DataSource datasource;
myConnection = dataSource.getConnection();
PreparedStatement stmt=(PreparedStatement) myConnection.createStatement();

String query ="SELECT uname,pword from users where uname='"+username+"' and pword='"+password+"'";
ResultSet rs=stmt.executeQuery(query);

while(rs.next()){
String uname = rs.getString("uname");
String pword = rs.getString("pword");


if(username.equals(uname) && password.equals(pword))
{
return mapping.findForward("success");
}
}
}catch (SQLException sqle)
{
getServlet().log("Connection.process", sqle);
}
return mapping.findForward("failure");

}
13 years ago
HI All,

Can any body help me to say what is process to store multiple data with ResultSet.

I want to write a code that shows multiple rows, selected by the previous jsp page, but i'm fail. It shows only one row in current page whether i select multiple rows in previous page.

My code is following: -


<% PreparedStatement ps=null;
Connection con=null;
ResultSet rs=null;
int m=0;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@172.16.90.139:1531:PROD","apps","apps");
String[] kys= request.getParameterValues("pkey");

ps=con.prepareStatement("SELECT distinct a.vendor_id,a.vendor_name,b.pan_no FROM po_vendors a,JA_IN_VENDOR_TDS_INFO_HDR b "+
"WHERE a.vendor_id=b.vendor_id and a.vendor_id=?");
for(int i=0;i<kys.length;i++)
{
ps.setString(1,kys[i]);
}

rs=ps.executeQuery();
while(rs.next())

{%>
<tr>
<td><input type=checkbox name=pkey value="<%= rs.getString(1) %>" /> </td>
<td><%= rs.getString(2) %> </td>
<td><%= rs.getString(3) %> </td>
<td><input type=text name=s_name value="" > </td>
</tr>
<%}
%>
13 years ago
JSP
Hi Rinni

Try to use following code.... think you will get success.....

String filename = "C:\\folder name where you save file\\filename";
response.setContentType("application/octet-stream");
String disHeader = "Attachment; Filename=\"filename\"";
response.setHeader("Content-Disposition", disHeader);
File fileToDownload = new File(filename);

InputStream in = null;
ServletOutputStream outs = response.getOutputStream();

try {
in = new BufferedInputStream
(new FileInputStream(fileToDownload));
int ch;
while ((ch = in.read()) != -1) {
outs.print((char) ch);
}
}
finally {
if (in != null) in.close(); // very important
}

outs.flush();
outs.close();
in.close();




:thumb:

[ May 05, 2008: Message edited by: Subhradip Podder ]
[ May 05, 2008: Message edited by: Subhradip Podder ]
13 years ago
JSP
HI All,

I have write program which can convert jsp to excel format & i use MIME type is <%@ page contentType="application/vnd.ms-excel" %>.

Now a days my company use open office 2.4. So my program is failed to convert open office(spreadsheet) format.

Can anybody help me to tell which MIME type i can use to solve this.

Following is my program.

<%@ page contentType="application/vnd.ms-excel" %>
<%@ page language="java" %>
<%@ page import="java.sql.*" %>
........................
.......................

<% PreparedStatement ps=null;
Connection con=null;
ResultSet rs=null;
int m=0;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@172.16.90.139:1531:PROD","apps","apps");
String f_date=request.getParameter("f_date");
String t_date=request.getParameter("t_date");

ps=con.prepareStatement("SELECT PV.VENDOR_NAME VNAME,FV.DESCRIPTION STATE,to_char(AIA.GL_DATE,'dd-mon-yyyy') GL_DATE,to_char
......................
.......................


ps.setString(1,f_date);
ps.setString(2,t_date);
rs=ps.executeQuery();

%>
</table>
</body>
</html
13 years ago
JSP
Hi All,

Can any body help me to send file download souce code using servlet or jsp

I'm failed to find-out in google.

please.......
13 years ago
JSP
HI Anshul Malpani,

Can you write me some code about this problem. Because i've limit knowledge about servlet.


Please help me.
13 years ago
JSP
HI All,

I have write a web enabled page to convert jsp to excel file using with POI,and successful to do that.

My problem is that when user acess that web page at client computer the file is save at server instead of client machine.

I want to save the file at their machine.

Please help me...I'm failed to solve it.

Following is my code.

<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFPrintSetup"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFCell"%>

...............................
...............................


<% PreparedStatement ps=null;
Connection con=null;
ResultSet rs=null;
int i=0;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@172.16.90.139:1531:PROD","apps","apps");
String f_date=request.getParameter("f_date");
String t_date=request.getParameter("t_date");

ps=con.prepareStatement("SELECT PV.VENDOR_NAME VNAME,FV.DESCRIPTION STATE,to_char(AIA.GL_DATE,'dd-mon-yyyy') GL_DATE,to_char(AIA.INVOICE_DATE,'dd-mon-yyyy') INV_DATE,AIA.INVOICE_NUM INV_NUM,AID.DISTRIBUTION_LINE_NUMBER LINE_NO,AID.AMOUNT AMOUNT, "+
"SUM(ROUND((NVL(AID.AMOUNT,0)*NVL((JIT.TAX_RATE),0)*0.01),0)) WCT FROM AP_INVOICE_DISTRIBUTIONS_ALL AID,AP_INVOICES_ALL AIA, "+
"JA_IN_TAX_CODES JIT,PO_VENDORS PV,FND_FLEX_VALUES_VL FV,GL_CODE_COMBINATIONS GLCC WHERE AIA.INVOICE_ID=AID.INVOICE_ID "+
"AND AIA.ACCTS_PAY_CODE_COMBINATION_ID=GLCC.CODE_COMBINATION_ID AND GLCC.SEGMENT3=FV.FLEX_VALUE AND FV.FLEX_VALUE_SET_ID='1009606' "+
"AND AID.ATTRIBUTE_CATEGORY='India Distributions' AND AID.ATTRIBUTE2 IS NOT NULL AND AID.ATTRIBUTE2=JIT.TAX_ID AND PV.VENDOR_ID=AIA.VENDOR_ID "+
"AND AIA.GL_DATE >=? AND AIA.GL_DATE <=? "+
"GROUP BY PV.VENDOR_NAME,FV.DESCRIPTION,AID.DISTRIBUTION_LINE_NUMBER,AID.AMOUNT,AIA.GL_DATE, "+
"AIA.INVOICE_DATE,AIA.INVOICE_NUM ORDER BY AIA.GL_DATE,AIA.INVOICE_NUM ");

ps.setString(1,f_date);
ps.setString(2,t_date);
rs=ps.executeQuery();


HSSFWorkbook hwb = new HSSFWorkbook();
HSSFSheet sheet = hwb.createSheet("new sheet");
HSSFSheet sheet1 = hwb.createSheet("second sheet");
HSSFRow rows = sheet.createRow((short)0);
HSSFCell cells = rows.createCell((short)0); cells.setCellValue("Vendor Name:");
...................

.....................
while(rs.next())


try{
i++;
{

HSSFRow row = sheet.createRow((short)0+i);
HSSFCell cell = row.createCell((short)0); cell.setCellValue(rs.getString(1));
HSSFCell cell1 = row.createCell((short)1); cell1.setCellValue(rs.getString(2));

}


FileOutputStream fileOut = new FileOutputStream("c:\\excel\\wct.xls");

hwb.write(fileOut);
fileOut.close();


}



catch ( Exception ex )
{
}
out.println("Your excel file has been generated,please see C drive:");


%>
13 years ago
JSP
HI Arjun,

Kindly write me the logout code using java-script,because i'm not well known java script.

Please help me.
13 years ago
JSP
HI All,
i'm trying to build a web page which permits the user to login before accessing the contents of the site. the login works fine (i did it using jsp), but i am not able to logout properly, that is, when i click on a "logout" hyperlink, it sends me to the proper page, but when i do "back" on my explorer, it gives me the previous page again. so my logout is pointless.

can anyone tell me how to prevent this from happening please?i don't know if i should use jsp, javascript or html to do this.
i need this urgently for my project.
thanks for replying as possible

My Log Out Code:-

<%@ page language="java" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>

<%
session.invalidate();
session=request.getSession(true);
response.sendRedirect("login.htm");
%>
13 years ago
JSP
Thank you again Ulf Dittmer. You are genius.
Again you help me.

In my program I missed to convert some parameter : to ?, and that is problem for create ArrayIndexOutOfBoundsException.

Now as per your suggestion I solve it.

Thanks............
:thumb:
HI All,

I'm face a problem with prepareStatement.
when i run my code,the compiler will give me a "java.lang.ArrayIndexOutOfBoundsException: 28
oracle.jdbc.driver.OracleSql.computeBasicInfo(OracleSql.java:925)
oracle.jdbc.driver.OracleSql.getSqlKind(OracleSql.java:608)
oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:1208)
oracle.jdbc.driver.T4CPreparedStatement.<init>(T4CPreparedStatement.java:29)
oracle.jdbc.driver.T4CDriverExtension.allocatePreparedStatement(T4CDriverExtension.java:70)
oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:881)
oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:787)
org.apache.jsp.report.std_005fcashflow_jsp._jspService(std_005fcashflow_jsp.java:79)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

"
.
i want to know that there is any limitation of caracter that we can fire within prepareStatement,because my caracter was 10,345.


I write my code like following........

("Select unit||'-'||unit_name Unit,account||'-'||account_name Account,SUM(Amount) Amount "+
"From "+
"(SELECT "+
"'UNAPP' TYPE, "+
"FL.SEGMENT4 UNIT, "+
"FL.SEGMENT5 ACCOUNT, "+
"FL.UNIT_NAME, "+
"FL.ACCOUNT_NAME, "+
"SUM(NVL(ACCOUNTED_CR,0)-NVL(ACCOUNTED_DR,0)) AS AMOUNT "+
"FROM "+
"AR_AEL_SL_REC_V ASR, "+
"PWC_FLEX_ACC_DESC_VL FL "+
"WHERE ASR.ACCT_LINE_TYPE IN ('UNAPP') "+
"AND ASR.ACCOUNTING_DATE BETWEEN ? AND ? "+
"AND ASR.TRX_HDR_ID IN "+
"(SELECT DISTINCT CASH_RECEIPT_ID FROM AR_CASH_RECEIPTS_V "+
"WHERE GL_DATE BETWEEN ? AND ?) "+
"AND ASR.CODE_COMBINATION_ID=FL.CODE_COMBINATION_ID "+
"GROUP BY "+
"FL.SEGMENT4, "+
"FL.SEGMENT5, "+
"FL.UNIT_NAME, "+
"FL.ACCOUNT_NAME "+
"UNION ALL "+
"SELECT "+
"'BANK_CH' TYPE, "+
"FL.SEGMENT4 UNIT, "+
"FL.SEGMENT5 ACCOUNT, "+
"FL.UNIT_NAME, "+
"FL.ACCOUNT_NAME, "+
"SUM(NVL(ACCOUNTED_CR,0)-NVL(ACCOUNTED_DR,0)) AS AMOUNT "+
"FROM "+
"AR_AEL_SL_REC_V ASR, "+
"PWC_FLEX_ACC_DESC_VL FL "+
"WHERE ASR.ACCT_LINE_TYPE IN ('BANK_CHARGES') "+
"AND ASR.TRX_HDR_ID IN "+
"(SELECT DISTINCT CASH_RECEIPT_ID FROM AR_CASH_RECEIPTS_V "+
"WHERE GL_DATE BETWEEN ? AND ?) "+
"AND ASR.ACCOUNTING_DATE BETWEEN ? AND ? "+
"AND ASR.CODE_COMBINATION_ID=FL.CODE_COMBINATION_ID "+
"GROUP BY "+
"FL.SEGMENT4, "+
"FL.SEGMENT5, "+
"FL.UNIT_NAME, "+
"FL.ACCOUNT_NAME "+
"UNION ALL "+
"SELECT "+
"'MISC'TYPE, "+
"FL.SEGMENT4 UNIT, "+
"FL.SEGMENT5 ACCOUNT, "+
"FL.UNIT_NAME, "+
"FL.ACCOUNT_NAME, "+
"SUM(NVL(ACCOUNTED_CR,0)-NVL(ACCOUNTED_DR,0)) AS AMOUNT "+
"FROM "+
"AR_AEL_SL_REC_V ASR, "+
"PWC_FLEX_ACC_DESC_VL FL "+
"WHERE ASR.ACCT_LINE_TYPE IN ('MISCCASH') "+
"AND ASR.TRX_HDR_ID IN "+
"(SELECT DISTINCT CASH_RECEIPT_ID FROM AR_CASH_RECEIPTS_V "+
"WHERE GL_DATE BETWEEN ? AND ?) "+
"AND ASR.ACCOUNTING_DATE BETWEEN ? AND ? "+
"AND ASR.CODE_COMBINATION_ID=FL.CODE_COMBINATION_ID "+
"GROUP BY "+
"FL.SEGMENT4, "+
"FL.SEGMENT5, "+
"FL.UNIT_NAME, "+
"FL.ACCOUNT_NAME "+
"UNION ALL "+
"SELECT "+
"'XCHANGE'TYPE, "+
"FL.SEGMENT4 UNIT, "+
"FL.SEGMENT5 ACCOUNT, "+
"FL.UNIT_NAME, "+
"FL.ACCOUNT_NAME, "+
"SUM(NVL(ACCOUNTED_CR,0)-NVL(ACCOUNTED_DR,0)) AS AMOUNT "+
"FROM "+
"AR_AEL_SL_REC_V ASR, "+
"PWC_FLEX_ACC_DESC_VLFL "+
"WHERE ASR.ACCT_LINE_TYPE IN ('EXCH_GAIN','EXCH_LOSS') "+
"AND ASR.TRX_HDR_ID IN "+
"(SELECT DISTINCT CASH_RECEIPT_ID FROM AR_CASH_RECEIPTS_V "+
"WHERE GL_DATE BETWEEN ? AND ?) "+
"AND ASR.ACCOUNTING_DATE BETWEEN ? AND ? "+
"AND ASR.CODE_COMBINATION_ID=FL.CODE_COMBINATION_ID "+
"GROUP BY "+
"FL.SEGMENT4, "+
"FL.SEGMENT5, "+
"FL.UNIT_NAME, "+
"FL.ACCOUNT_NAME "+
"UNION ALL "+
"SELECT "+
"'ON_ACC'TYPE, "+
"FL.SEGMENT4UNIT, "+
"FL.SEGMENT5ACCOUNT, "+
"FL.UNIT_NAME, "+
"FL.ACCOUNT_NAME, "+
"SUM(NVL(ACCOUNTED_CR,0)-NVL(ACCOUNTED_DR,0)) AS AMOUNT "+
"FROM "+
"AR_AEL_SL_REC_V ASR, "+
"PWC_FLEX_ACC_DESC_VLFL "+
"WHERE ASR.ACCT_LINE_TYPE IN ('ACC') "+
"AND ASR.TRX_HDR_ID IN "+
"(SELECT DISTINCT CASH_RECEIPT_ID FROM AR_CASH_RECEIPTS_V "+
"WHERE GL_DATE BETWEEN ? AND ?) "+
"AND ASR.ACCOUNTING_DATE BETWEEN ? AND ? "+
"AND ASR.CODE_COMBINATION_ID=FL.CODE_COMBINATION_ID "+
"GROUP BY "+
"FL.SEGMENT4, "+
"FL.SEGMENT5, "+
"FL.UNIT_NAME, "+
"FL.ACCOUNT_NAME "+
"UNION ALL "+
"SELECT "+
"'UNID'TYPE, "+
"FL.SEGMENT4 UNIT, "+
"FL.SEGMENT5 ACCOUNT, "+
"FL.UNIT_NAME, "+
"FL.ACCOUNT_NAME, "+
"SUM(NVL(ACCOUNTED_CR,0)-NVL(ACCOUNTED_DR,0)) AS AMOUNT "+
"FROM "+
"AR_AEL_SL_REC_V ASR, "+
"PWC_FLEX_ACC_DESC_VLFL "+
"WHERE ASR.ACCT_LINE_TYPE IN ('UNID') "+
"
...........
..........
..........

Please help me.....