MailEnable - Create Account - asp.net

I'm trying to create an e-mail with MailEnable
based http://www.mailenable.com/developers/NET_SignUp.zip
MailEnable.Administration.Login oLogin = new MailEnable.Administration.Login();
oLogin.Account = iCliente.URL;
oLogin.LastAttempt = -1;
oLogin.LastSuccessfulLogin = -1;
oLogin.LoginAttempts = -1;
oLogin.Password = txt_Senha.Text;
oLogin.Rights = "";
oLogin.Status = -1;
oLogin.UserName = txt_Email + "#" + iCliente.URL;
if (oLogin.GetLogin() != 1)
{
oLogin.LastAttempt = 0;
oLogin.LastSuccessfulLogin = 0;
oLogin.LoginAttempts = 0;
oLogin.Password = txt_Senha.Text;
oLogin.Rights = "USER";
oLogin.Status = 1;
}
MailEnable.Administration.Mailbox mailBoxCreate = new MailEnable.Administration.Mailbox();
mailBoxCreate.Postoffice = iCliente.URL;
mailBoxCreate.MailboxName = txt_Email.Text;
mailBoxCreate.RedirectAddress = txt_Redirect.Text;
mailBoxCreate.RedirectStatus = 0;//recuperar valor da checkbox
mailBoxCreate.Limit = 51200; //-1 for unlimited
mailBoxCreate.Status = 1;
mailBoxCreate.AddMailbox();
MailEnable.Administration.AddressMap mailAMap = new MailEnable.Administration.AddressMap();
mailAMap.Account = iCliente.URL;
mailAMap.DestinationAddress = "[SF:" + iCliente.URL + "/" + txt_Email.Text + "]";
mailAMap.SourceAddress = "[SMTP:" + txt_Email.Text + "#" + iCliente.URL + "]";
mailAMap.AddAddressMap();
But does not work, it creates the email but no password!
:(

Follow my class running perfect.
using System;
using System.Data.SqlClient;
using System.IO;
using System.Xml.XPath;
using MailEnable;
namespace BLL
{
public class MailEnable_Geral
{
public string _Email { get; set; }
public bool CriarEmail(string _senha, string _redirect, long _ativarRedirect)
{
string[] vPostoffice = _Email.Split('#');
string _username = vPostoffice[0];
string _postoffice = vPostoffice[1];
string _domain=_postoffice;
bool _retorno = true;
try
{
MailEnable.Administration.Mailbox mb = new MailEnable.Administration.Mailbox();
mb.Postoffice = _postoffice;
mb.MailboxName = _username;
mb.Host = _domain;
mb.Limit = 51200;//50MB
mb.RedirectAddress = _redirect;
mb.RedirectStatus = _ativarRedirect;//Ativa ou desativa Redirect
mb.Status = 1;
mb.AddMailbox();
MailEnable.Administration.Login login = new MailEnable.Administration.Login();
login.Account = _postoffice;
login.Description = _username + " at " + _domain;
login.Host = _domain;
login.Rights = "USER";
login.Status = 1;
login.Password = _senha;
login.UserName = _username + "#" + _postoffice;
login.AddLogin();
MailEnable.Administration.AddressMap map = new MailEnable.Administration.AddressMap();
map.Account = _postoffice;
map.DestinationAddress = "[SF:" + _postoffice + "/" + _username + "]";
map.SourceAddress = "[SMTP:" + _username + "#" + _domain + "]";
map.Scope = "";
if (map.AddAddressMap() == 0)
{
throw new Exception("Failed address map");
}
}
catch (Exception e)
{
_retorno = false;
}
return _retorno;
}
}
}

Related

Asp.Net Upload Imagem cloudinary

Good afternoon!
I have problems uploading images to a defined folder. As you can see, in my code I can upload to the cloudinary root, but not to a specific folder I created.
Cloudinary cloudinary = new Cloudinary(account);
string NomeImagem = "";
string TipoImagem = "";
string Versao = "";
byte[] binData = null;
string result = string.Empty;
if (Request.Files.Count > 0)
{
if (Request.Files["FotoURL"].ContentLength > 0)
{
using (BinaryReader b = new BinaryReader(Request.Files["FotoURL"].InputStream))
{
binData = b.ReadBytes(Request.Files["FotoURL"].ContentLength);
}
string teste = Convert.ToBase64String(binData);
byte[] imageBytes = Convert.FromBase64String(Convert.ToBase64String(binData));
using (MemoryStream ms = new MemoryStream(imageBytes))
{
DirectoryInfo dir = new DirectoryInfo(Server.MapPath("."));
string diretorio = dir.FullName.ToString();
try
{
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(IdUsuario + "Perfiltemp.jpg", ms)
};
var uploadResult = cloudinary.Upload(uploadParams);
NomeImagem = uploadResult.JsonObj["public_id"].ToString();
TipoImagem = uploadResult.Format.ToString();
Versao = "v" + uploadResult.Version.ToString();
dados += "&FotoURL=http://res.cloudinary.com/diretor/aceleramei/image/upload/" + Versao + "/" + NomeImagem + "." + TipoImagem;
}
catch (Exception e)
{
string msg = e.ToString();
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(#"" + Server.MapPath("~") + "\\Content\\layout\\img\\300x200.gif")
};
var uploadResult = cloudinary.Upload(uploadParams);
NomeImagem = uploadResult.JsonObj["public_id"].ToString();
TipoImagem = uploadResult.Format.ToString();
Versao = "v" + uploadResult.Version.ToString();
// dados += "&FotoURL=http://res.cloudinary.com/diretor/image/upload/" + Versao + "/" + NomeImagem + "." + TipoImagem;
}
}
Solução
string NomeImagem = "";
string TipoImagem = "";
string Versao = "";
// string Pasta = "teste";
byte[] binData = null;
string result = string.Empty;
if (Request.Files.Count > 0)
{
if (Request.Files["FotoURL"].ContentLength > 0)
{
using (BinaryReader b = new BinaryReader(Request.Files["FotoURL"].InputStream))
{
binData = b.ReadBytes(Request.Files["FotoURL"].ContentLength);
}
string teste = Convert.ToBase64String(binData);
byte[] imageBytes = Convert.FromBase64String(Convert.ToBase64String(binData));
using (MemoryStream ms = new MemoryStream(imageBytes))
{
DirectoryInfo dir = new DirectoryInfo(Server.MapPath("teste"));
string diretorio = dir.FullName.ToString();
try
{
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(IdUsuario + "Perfiltemp.jpg" , ms),
PublicId = $"aceleramei/{System.IO.Path.GetFileName(IdUsuario)}",
EagerAsync = true
};
var uploadResult = cloudinary.Upload(uploadParams);
NomeImagem = uploadResult.JsonObj["public_id"].ToString();
TipoImagem = uploadResult.Format.ToString();
Versao = "v" + uploadResult.Version.ToString();
dados += "&FotoURL=http://res.cloudinary.com/diretor/image/upload/" + Versao + "/" + NomeImagem + "." + TipoImagem;
}
catch (Exception e)
{
string msg = e.ToString();
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(#"" + Server.MapPath("~") + "\\Content\\layout\\img\\300x200.gif"),
PublicId = $"aceleramei/{System.IO.Path.GetFileName("")}",
EagerAsync = true
};
var uploadResult = cloudinary.Upload(uploadParams);
NomeImagem = uploadResult.JsonObj["public_id"].ToString();
TipoImagem = uploadResult.Format.ToString();
Versao = "v" + uploadResult.Version.ToString();
// dados += "&FotoURL=http://res.cloudinary.com/diretor/image/upload/" + Versao + "/" + NomeImagem + "." + TipoImagem;
}
}
}
else
{
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(#"" + Server.MapPath("~") + "\\Content\\layout\\img\\300x200.gif"),
PublicId = $"aceleramei/{System.IO.Path.GetFileName("")}",
EagerAsync = true
};
var uploadResult = cloudinary.Upload(uploadParams);
NomeImagem = uploadResult.JsonObj["public_id"].ToString();
TipoImagem = uploadResult.Format.ToString();
Versao = uploadResult.Version.ToString();
dados += "&FotoURL=";
}
}
else
{
var uploadParams = new ImageUploadParams()
{
File = new FileDescription(#"" + Server.MapPath("~") + "\\Content\\layout\\img\\300x200.gif"),
PublicId = $"aceleramei/{System.IO.Path.GetFileName("")}",
EagerAsync = true
};
var uploadResult = cloudinary.Upload(uploadParams);
NomeImagem = uploadResult.JsonObj["public_id"].ToString();
TipoImagem = uploadResult.Format.ToString();
Versao = "v" + uploadResult.Version.ToString();
dados += "&FotoURL=";

I am working with asp.net and i try to display multiple div dynamically it working but every time display same slider data

#region fillAllData4
private void fillAllData4()
{
clsCategory objCategory = new clsCategory(true);
clsProductMain objProduct = new clsProductMain(true);
objCategory.getDropDownMenu();
objProduct.getProduct();
string str = string.Empty;
int i = 0;
// int j = 0;
if (objCategory.ListclsCategory.Count > 0)
{
for (i = 0; i < objCategory.ListclsCategory.Count; i++)
{
cat.InnerHtml = objCategory.ListclsCategory[0].CategoryName;
cat1.InnerHtml = objCategory.ListclsCategory[1].CategoryName;
cat2.InnerHtml = objCategory.ListclsCategory[2].CategoryName;
cat3.InnerHtml = objCategory.ListclsCategory[3].CategoryName;
string[] filePaths = Directory.GetFiles(Server.MapPath("~/images/Saree/"));
int j = 0;
foreach (string filePath in filePaths)
{
string fileName = Path.GetFileName(filePath);
str += #"<div><div><img class='imges' src='images/Saree/" + fileName + #"' /></div>
<div class='sname'>" + objProduct.ListclsProductMain[j].ProductName + #"</div>
<div class='sname2'>" + objProduct.ListclsProductMain[j].MRP + #"</div></div>";
j++;
}
slider3.InnerHtml = str;
slider4.InnerHtml = str;
slider5.InnerHtml = str;
slider6.InnerHtml = str;
//System.Web.UI.HtmlControls.HtmlGenericControl createDiv =
//new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
//createDiv.ID = "createDiv";
//createDiv.InnerHtml =str;
//this.Controls.Add(createDiv);
}
}
}
#endregion

How to write two Handlers using Switch Case

i wrote two handlers but i need to write now only one handler using switch case how to write i tried but not working. please help me. this is my two handlers code i want that in switch case.please solve this problem
public void ProcessRequest(HttpContext context)
{
string fname = string.Empty;
string ffname = string.Empty;
string m_Result = string.Empty;
DataTable dt = new DataTable();
Guid id = Guid.NewGuid();
if (context.Request.Files.Count > 0)
{
HttpFileCollection files = context.Request.Files;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
if (HttpContext.Current.Request.Browser.Browser.ToUpper() == "IE" || HttpContext.Current.Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
{
string[] testfiles = file.FileName.Split(new char[] { '\\' });
fname = testfiles[testfiles.Length - 1];
}
else
{
fname = file.FileName;
ffname = "~/Adds_uploads/" + fname;
}
string p = Path.GetFileNameWithoutExtension(fname);
fname = Path.Combine(context.Server.MapPath("~/Adds_uploads/"), p);
file.SaveAs(fname + id + Path.GetExtension(ffname));
string dirName1 = new DirectoryInfo(fname).Name;
FileInfo fInfo = new FileInfo(ffname);
String dirName = fInfo.Directory.Name + '/' + dirName1 + id + Path.GetExtension(ffname);
HttpContext.Current.Response.Write(JsonConvert.SerializeObject(dirName));
//RAID = context.Request.QueryString["RA_ID"].ToString();
//UploadFileToDB(file, RAID);
}
}
}
public bool IsReusable {
get {
return false;
}
}
2nd Handler
public void ProcessRequest(HttpContext context)
{
string fname = string.Empty;
string ffname = string.Empty;
string m_Result = string.Empty;
DataTable dt = new DataTable();
Guid id = Guid.NewGuid();
if (context.Request.Files.Count > 0)
{
HttpFileCollection files = context.Request.Files;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
if (HttpContext.Current.Request.Browser.Browser.ToUpper() == "IE" || HttpContext.Current.Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
{
string[] testfiles = file.FileName.Split(new char[] { '\\' });
fname = testfiles[testfiles.Length - 1];
}
else
{
fname = file.FileName;
ffname = "~/Fileuploads/" + fname;
}
string p = Path.GetFileNameWithoutExtension(fname);
fname = Path.Combine(context.Server.MapPath("~/Fileuploads/"), p);
file.SaveAs(fname + id + Path.GetExtension(ffname));
string dirName1 = new DirectoryInfo(fname).Name;
FileInfo fInfo = new FileInfo(ffname);
String dirName = fInfo.Directory.Name + '/' + dirName1 + id + Path.GetExtension(ffname);
HttpContext.Current.Response.Write(JsonConvert.SerializeObject(dirName));
//RAID = context.Request.QueryString["RA_ID"].ToString();
//UploadFileToDB(file, RAID);
}
}
}
public bool IsReusable {
get {
return false;
}
}
I think the only difference if the upload path. I would suggest you to pass along another input form the view and then determine the upload path based on that.
i.e
you would have
//for case one
<input type='hidden' name='uploadType' value='files' />
//for case two
<input type='hidden' name='uploadType' value='adds' />
inside your individual file upload forms and then on your action method you can just use
var mappedDirectory = HttpContext.Current.Request.Form["uploadType"].ToString() == "adds" ? "~/Adds_uploads/" : "~/Fileuploads/";
and use this string in your fname construct. So your new method would be like
public void ProcessRequest(HttpContext context)
{
var mappedDirectory = HttpContext.Current.Request.Form["uploadType"].ToString() == "adds" ? "~/Adds_uploads/" : "~/Fileuploads/";
string fname = string.Empty;
string ffname = string.Empty;
string m_Result = string.Empty;
DataTable dt = new DataTable();
Guid id = Guid.NewGuid();
if (context.Request.Files.Count > 0)
{
HttpFileCollection files = context.Request.Files;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
if (HttpContext.Current.Request.Browser.Browser.ToUpper() == "IE" || HttpContext.Current.Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
{
string[] testfiles = file.FileName.Split(new char[] { '\\' });
fname = testfiles[testfiles.Length - 1];
}
else
{
fname = file.FileName;
ffname = mappedDirectory + fname;
}
string p = Path.GetFileNameWithoutExtension(fname);
fname = Path.Combine(context.Server.MapPath(mappedDirectory), p);
file.SaveAs(fname + id + Path.GetExtension(ffname));
string dirName1 = new DirectoryInfo(fname).Name;
FileInfo fInfo = new FileInfo(ffname);
String dirName = fInfo.Directory.Name + '/' + dirName1 + id + Path.GetExtension(ffname);
HttpContext.Current.Response.Write(JsonConvert.SerializeObject(dirName));
//RAID = context.Request.QueryString["RA_ID"].ToString();
//UploadFileToDB(file, RAID);
}
}
}

How to use and improve wakhtmltopdf performance?

I have my aspx pages , and some logic is written in code behind to bind the data of aspx pages.Now using wkhtmltopdf i am sending these files to convert into pdf files.Its work very well when the data is smaller in size however when the data comes in larger side for that page the wkhtmltopdf stops working and doesnt create any pdf file.
Can you suggest any way to overcome this problem. What i tried was limiting the data.. for example i have repeater control on my page if that controls binds 350 record i am only taking 20 records , but also if size of those 20 records are large it happens the same
the also next option i tried is my giving the parameter inside
Process myProcess = Process.Start(startInfo);
myProcess.WaitForExit(few seconds);
but it still doesnt work
Please suggest
Process myProcess = Process.Start(startInfo);
string error = myProcess.StandardError.ReadToEnd();
myProcess.WaitForExit();
myProcess.Close();
objZip.AddFile(destinationFile, "Files");
myProcess.Dispose();
myProcess = null;
This is the answer => what happen is when u start process , and wait for exit () both creates a deadlock somtimes which hammers the performance .. by adding readtoend() method before waitforexit() clears the deadlock and then continues further processing ...
this solves my problem.
The reason i am showing complete solution is that , wkhtmltopdf is very good for creating dynamic pdf files , but this is free tool as well and hence very limited documentation for this ..
private void ProcessHtmlToPdf(List<ExportToPdfCategories> lstExportToPdfCategories)
{
try
{
string pdfExportPath = string.Empty;
string PDFdeletePath = string.Empty;
string deletePath = string.Empty;
string PdfSavePath = string.Empty;
if (lstExportToPdfCategories != null)
{
foreach (var item in lstExportToPdfCategories)
{
path = "";
pdfExportPath = profile + ApConfig.CurrentCompany.CompId + "/" + objExpDetails.AddedForId.ToString() + "/" + item.HeaderCategory;
PDFdeletePath = profile + ApConfig.CurrentCompany.CompId + "/" + objExpDetails.AddedForId.ToString();
PdfSavePath = profile + ApConfig.CurrentCompany.CompId + "/" + objExpDetails.AddedForId.ToString() + "/" + item.HeaderCategory;
htmlpath = profile + ApConfig.CurrentCompany.CompId + "/" + objExpDetails.AddedForId.ToString() + "/" + item.HeaderCategory;
deletePath = Server.MapPath(PDFdeletePath);
string ClearDirectory = Server.MapPath(PdfSavePath);
if (Directory.Exists(deletePath))
{
//Directory.Delete(ClearDirectory, true);
//Directory.Delete(deletePath, true);
}
if (!Directory.Exists(Server.MapPath(pdfExportPath)))
{
Directory.CreateDirectory(Server.MapPath(pdfExportPath));
}
string name =
pdfExportPath = pdfExportPath + "/" + objExpDetails.FirstName + "." + objExpDetails.LastName + "-" + item.HeaderCategory + "_" + (drpYear.SelectedValue != "0" ? Convert.ToString(drpYear.SelectedValue) : System.DateTime.Now.Year.ToString()) + ".pdf";
objpath = Server.MapPath(pdfExportPath);
//this will create html mockup
//item.WebsiteUrl = CreateTemportHtmlFile(item.HeaderCategory, PdfSavePath, item.WebsiteUrl);
if (path == "")
{
path = CreateTemportHtmlFile(PdfSavePath, item.HeaderCategory);
}
HtmlToPdf(item.WebsiteUrl, objpath, path);
}
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + objExpDetails.FirstName + "." + objExpDetails.LastName + "-actusdocs.zip");
Response.ContentType = "application/zip";
objZip.Save(Response.OutputStream);
Response.End();
}
}
catch (Exception ex)
{
//SendEmail.SendErrorMail("ProcessHtmlToPdf method : ", ex.Message + ex.StackTrace, objExpDetails);
}
}
//Method overloading
//this is for testing html pages(not in used during main running)
private string CreateTemportHtmlFile(string categoryName, string htmlMockupSavingPath, string websiteURL)
{
try
{
string sessionId = Session.SessionID;
int employeeId = Convert.ToInt32(hdnEmployeeId.Value);
htmlMockupSavingPath = Server.MapPath(htmlMockupSavingPath) + "\\" + categoryName + ".html";
StreamWriter sw;
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(websiteURL);
myRequest.Method = "GET";
WebResponse myResponse = myRequest.GetResponse();
StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
string result = sr.ReadToEnd();
sw = File.CreateText(htmlMockupSavingPath);
sw.WriteLine(result);
sw.Close();
Response.WriteFile(htmlMockupSavingPath);
}
catch (Exception ex)
{
SendEmail.SendErrorMail("CreateTemportHtmlFile method : ", ex.Message + ex.StackTrace, objExpDetails);
}
return htmlMockupSavingPath;
}
private string CreateTemportHtmlFile(string PdfSavePath, string categoryName)
{
try
{
string sessionId = Session.SessionID;
int employeeId = Convert.ToInt32(hdnEmployeeId.Value);
PdfSavePath = Server.MapPath(PdfSavePath) + "\\BindHeader.html";
htmlpath = htmlpath.Substring(1);
htmlpath = ConfigurationManager.AppSettings["pdfUrlPath"].ToString() + htmlpath + "/BindHeader.html";
string exportedYear = (drpYear.SelectedValue == "0" ? System.DateTime.Now.Year.ToString() : drpYear.SelectedValue);
StreamWriter sw;
if (categoryName == "MidYearAppraisal" || categoryName == "EndYearAppraisal")
{
myRequest = (HttpWebRequest)WebRequest.Create(ConfigurationManager.AppSettings["pdfUrlPath"] + "/User/UserPdfReports/UserPdfHeaderforAppraisal.aspx?session=" + sessionId + "&empId=" + employeeId + "&catName=" + categoryName + "&expYear=" + exportedYear);
}
else
{
myRequest = (HttpWebRequest)WebRequest.Create(ConfigurationManager.AppSettings["pdfUrlPath"] + "/User/UserPdfReports/UserPdfHeader.aspx?session=" + sessionId + "&empId=" + employeeId + "&catName=" + categoryName + "&expYear=" + exportedYear);
}
myRequest.Method = "GET";
WebResponse myResponse = myRequest.GetResponse();
StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
string result = sr.ReadToEnd();
sw = File.CreateText(PdfSavePath);
sw.WriteLine(result);
sw.Close();
Response.WriteFile(PdfSavePath);
}
catch (Exception ex)
{
SendEmail.SendErrorMail("CreateTemportHtmlFile method : ", ex.Message + ex.StackTrace, objExpDetails);
}
return htmlpath;
}
private void HtmlToPdf(string website, string destinationFile, string path)
{
try
{
string hrmlPath = ConfigurationManager.AppSettings["pdfUrlPath"].ToString() + "/user/UserPdfReports/FooterPdfReports.html";
ProcessStartInfo startInfo = new ProcessStartInfo();
string switches = "";
switches += "--header-html " + path + " --footer-html " + hrmlPath;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
startInfo.FileName = "C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe";
startInfo.Arguments = switches + " " + website + " " + destinationFile;
Process myProcess = Process.Start(startInfo);
string error = myProcess.StandardError.ReadToEnd();
myProcess.WaitForExit();
myProcess.Close();
objZip.AddFile(destinationFile, "Files");
myProcess.Dispose();
myProcess = null;
}
catch (Exception ex)
{
//SendEmail.SendErrorMail("HtmlToPdf : ", ex.Message + ex.StackTrace, objExpDetails);
}
}

Java servlet - export to an excell using string buffer

I am new to JAVA. I am trying to export Excel through servlet from resultset.
When i am trying to store data in String buffer the it is not actually saving it.
Testfirst.java
String assingee_name = req.getParameter("firstName");
String track_name = req.getParameter("track");
String sla_id = req.getParameter("sla");
StringBuffer sb = new StringBuffer();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:Databasethree");
stmt = con.createStatement();
//pw.println("'" +assingee_name + "'");
length = track_name.length();
if (length > 0) {
rs = stmt.executeQuery("SELECT* FROM casedetails where track =" + "'" + track_name + "'");
}
length = sla_id.length();
if (length > 0) {
//rs = stmt.executeQuery("SELECT* FROM casedetails where case_age >"+"'" +sla_id + "'");
rs = stmt.executeQuery("SELECT* FROM cdoscase where Incident_Submit_Fiscal_Year=" + "'" + sla_id + "'");
}
length = assingee_name.length();
if (length > 0) {
rs = stmt.executeQuery("SELECT* FROM casedetails where Assingee_name =" + "'" + assingee_name + "'");
}
pw.println("<html><body>");
pw.println("<H1> CDOS Case Management Version 1.1 </H1>");
pw.println("<Head><style>table,th,td{border:1px solid black;}</style></head>");
pw.println("<table>");
ResultSetMetaData rm = rs.getMetaData();
int clm = rm.getColumnCount();
StringBuffer sb1 = new StringBuffer();
String sb2 = new String();
for (int j = 1; j <= clm; j++) {
sb2 = rm.getColumnName(j);
pw.println("<th>");
pw.println(sb2);
pw.println("</th>");
}
ArrayList Rows = new ArrayList();
ArrayList row = new ArrayList();
Object a = new Object();
int jj = 0; // to find out the number rows
while (rs.next()) {
jj = jj + 1;
pw.println("<tr>");
for (int i = 1; i <= clm; i++) {
//data1[i]=rs.getString(i);
pw.println("<td>");
//pw.println(rs.getObject(i).toString());
pw.println(rs.getString(i));
pw.println("</td>");
sb2.append(rs.getString(i);
//row.add(rs.getString(i));
//sb2=sb2+rs.getObject(i).toString();
}
pw.println("</tr>");
} sb1.append("fd");
//Rows.add(row);
pw.println("Total Records found" + sb1);
pw.println("</table>");
//sb2=sb2+rs.getObject(clm).toString();
//sb1.append(sb2);
//sb1.append(sb2);
a = rs.getString(4).toString();
pw.println("this is data " + a);
pw.println("<p>");
pw.println("<td>Do you want to download report </td>");
req.setAttribute("data", Rows);
pw.println("<input type=\"submit\" name =\"submit1\" value=\"Export To Excel\">");
pw.println("</form>");
} catch (SQLException e) {
pw.println(e.getNextException());
} catch (ClassNotFoundException e) {
pw.println(e.getException());
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (stmt != null) {
stmt.close();
stmt = null;
}
if (con != null) {
con.close();
con = null;
}
} catch (Exception e) {
pw.close();
}
}
}
Any help on this is highly appreciated.
Thanks,
SR

Resources