How to Terminate JSP Process
use:
out.close(...
Saturday, December 21, 2013
How to generate .XLS file in Java using Apache POI
How to generate .XLS file in Java using Apache POI
String contextName = request.getContextPath().substring(1);
HttpSession hs = request.getSession();
String path = hs.getServletContext().getRealPath("/" +
contextName);
char pathSep = new File(path).separatorChar;
path = path.substring(0, path.lastIndexOf(pathSep + contextName));
path = path...
How to generate .XLSX file in Java using Apache POI
How to generate .XLSX file in Java using Apache POI
First you need to download from
apache site:
http://www.apache.org/dyn/closer.cgi/poi/dev/src/poi-src-3.8-beta3-20110606.zip
Extract zip file and copy listed below file in you Libraries folder
under NetBeans.
1)
poi-3.9-20121203.jar
2)
poi-examples-3.9-20121203.jar
3)
poi-excelant-3.9-20121203.jar
4)
poi-ooxml-3.9-20121203.jar
5)
poi-ooxml-schemas-3.9-20121203.jar
6)
poi-scratchpad-3.9-20121203.jar
7)
xmlbeans-2.3.0.jar
8)
dom4j-1.6.1.jar
Create...
Html to pdf in java struts.
Html to pdf in java struts.
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.PageSize;
import com.lowagie.text.html.simpleparser.HTMLWorker;
import com.lowagie.text.html.simpleparser.StyleSheet;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.codec.Base64;
import java.util.ArrayList;
import...
Friday, November 15, 2013
image quality in iTextSharp
How to improve image quality in iTextSharp.
I was working in question paper project. in this project I need to generate PDF file from images. but when I generated the PDF file, image's quality was so bad. so to overcome this problem I have used listed below code.
System.Drawing.Image image = System.Drawing.Image.FromFile("myimage.jpg");
iTextSharp.text.Document...
Accept only numeric character with BACKSPACE and TAB button facility
Accept only numeric character with BACKSPACE and TAB button facility.
When you enter some numeric value in age or amount like textbox then you not need to enter any other character. there are lot of script available in the internet about this. but they don't support BACKSPACE and TAB button facility. here are listed below code will...
Sunday, November 10, 2013
Post multiple and return values from JSON in JSP
JSON is very lightweight than XML. Here is the some hard JSON example with multiple values post and
multiple return values.
I have used "json-simple-1.1.1.jar" , so you need to download it.
index.jsp
---------------------
<%@ page import="org.json.JSONObject"%>
<%@ page import="java.io.PrintWriter"%>
<script src="jquery-1.10.2.js"...
Simple JSON in JSP
Simple JSON in JSP
JSON is very lightweight than XML.Here is the simple example of JSON with java.
I have used "json-simple-1.1.1.jar" , so you need to download it.
index.jsp
---------------------
<%@ page import="org.json.JSONObject"%>
<%@ page import="javax.json.Json"%>
<%@ page import="java.io.PrintWriter"%>
<script src="jquery-1.10.2.js"...
Saturday, November 02, 2013
Show records without class in hibernate and struts
Show all records without pojo class in hibernate and struts
Struts and Hibernate if you need to show all records from database table then you need to create a pojo class...in some cases you not need to use pojo class then how can you achieve to show all records? I have faced the same problem and overcome it with listed below code.
In query.hbm.xml...
Friday, October 25, 2013
ALTERNATE OF OR ANY OTHER LOGIC TAG IN STRUTS
ALTERNATE OF <logic:equal> OR ANY OTHER LOGIC TAG IN STRUTS
----------------------------------------------------------------------------------------
We need to write very much <logic:equal name> if there are lot of if conditions in you page...so how we use native if condition in struts. I have faced the same problem and find the solution....
Ajax in struts
How to use ajax in struts and hibernate.
Ajax is very important in website coding.
Here I am demonstrating how to use jquery ajax in struts and hibernate.
struts-config.xml
--------------------------
<action input="/" path="/amittest" scope="request" type="com.test.actions.AmitTestAction" parameter="method">
<forward name="success" path="/Webs/Input/amittest.jsp"/>
</action>
====================================================
query.hbm.xml
-----------------------------------
<?xml...
Saturday, October 19, 2013
java.lang.OutOfMemoryError: PermGen space in netbeans
java.lang.OutOfMemoryError: PermGen space in netbeans
How to solve it in netbeans:
1- Right click on server
2- properties
3- select platform
4-in VM option paste as : -Xmx512m -Xms512m -XX:MaxPermSize=512m
java.lang.OutOfMemoryError: PermGen space in netbeans...
Thursday, October 10, 2013
DispatchMapping does not define a handler property
You may face this error while working on java struts:
"DispatchMapping[/login] does not define a handler property"
Answer of this issue is "parameter attribute mention in struts-config for method of Action clas...
Cannot retrieve definition for form bean on action
javax.servlet.jsp.JspException: Cannot retrieve definition for form bean stdname on action regist
Ans:spelling mistake in tags, so check it and correct it in struts-config.xml fi...
Action missing resource in key method map
Action missing resource in key method map
Ans:It means the you have put some spaces in .properties file or missing some property key and its val...
Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.JasperException: javax.servlet.
ServletException: javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
root cause
javax.servlet.jsp.JspException: Cannot find ActionMappings...
message No action instance for path / could be created error in struts
message No action instance for path /getcity could be created in struts
description The server encountered an internal error (No action instance for path /getcity could be created) that prevented it from fulfilling this request.
Ans: it means that you miss-spelled class information just see [type="con.test.action.DoLogin"] it must be type="com.test.action.DoLogin"<action...
Action does not contain specified method (check logs)
javax.servlet.ServletException: java.lang.
NoSuchMethodException: Action[/salary] does not contain specified method (check logs)
java.lang.NoSuchMethodException: Action[/salary] does not contain specified method (check logs)
Ans: This means "salary" method must be a text in the .jsp file:public ActionForward salary(ActionMapping mapping, ActionForm...
Cannot find message resources under key org.apache.struts.action.MESSAGE
Cannot find message resources under key org.apache.struts.action.MESSAGE
javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.
MESSAGEjavax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
Ans:1- create a package:...