monicka rk akilan

Greenhorn
+ Follow
since Jan 04, 2013
Merit badge: grant badges
For More
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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by monicka rk akilan

I have one java web application developed in spring. Now i want to split the application into multiple jars based on modules for different customer requirement.

I followed package structure for different modules like

I want to make these into two jars based on the module also having some packages and login module.

Am using Eclipse and ANT

I don't know how and where to start. Please advice me.

Advance Thanks for your valuable comments.
10 years ago
Hello am using spring 3.1.2

i got this error
java.lang.ClassCastException: org.springframework.web.servlet.mvc.ParameterizableViewController cannot be cast to org.springframework.web.method.HandlerMethod

===========================================================================================================================

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
HttpSession currentSession = request.getSession();
HandlerMethod handlerMethod = (HandlerMethod) handler;
Class<? extends Object> entryClass = handlerMethod.getBean().getClass();

if (entryClass.isAnnotationPresent(Navigation.class)) {
@SuppressWarnings("unchecked")
List<NavigationEntry> prevPath = (List<NavigationEntry>) currentSession.getAttribute(NAVIGATION_PATH);
if (prevPath == null) {
prevPath = new ArrayList<NavigationEntry>();
}

List<NavigationEntry> basePath = buildBasePath(prevPath, entryClass);
NavigationEntry entry = generateNavigationEntry(entryClass, currentSession);
basePath.add(entry);
currentSession.setAttribute(NAVIGATION_PATH, basePath);
} else {
clearNavigationPath(currentSession);
}
}

====================================================================================================

i got this error in underlined line.

Please help me to sort out of this issue
10 years ago
Hello all,

I am trying to save and retrieve from database.
Saving is working perfectly . but when i try to retrive
its showing error in the place of casting ByteArrayInputStream to multipart


if ((fileList.get(0).getFileType()).equals("abc")) {
commonVo.gettInfoVO().setStPhoto(

=================================================================
(MultipartFile) fileList.get(0).getInputStream());
here i got error as

SEVERE: Servlet.service() for servlet Havila threw exception
java.lang.ClassCastException: java.io.ByteArrayInputStream cannot be cast to org.springframework.web.multipart.MultipartFile
=================================================================

}


help me to resolve this problem.

10 years ago
Hello every one,

Am using struts1.3. Am struking in printing when i tried in local host its working perfectly.
But when i move to live its shows exception.
--------------------------------------------------------------------------------------------------------------------------------------
ype Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.awt.HeadlessException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:520)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:427)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

java.awt.HeadlessException
sun.print.PSPrinterJob.printDialog(PSPrinterJob.java:422)
report.Printing.Print.printToPrinter(Print.java:97)
report.Printing.Print.main(Print.java:45)
com.lr.LRMasterAction.Print(LRMasterAction.java:66)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

----------------------------------------------------------------------------------------------------------------------------------
here is my coding......

package report.Printing;

import com.dao.dto.LrMasterDTO;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class LRText implements Printable{
int fontSize=8;
LrMasterDTO lm;

FileWriter outFile ;
public void setLr(LrMasterDTO lm)
{
this.lm=lm;
} public int print(Graphics g, PageFormat pf, int pageIndex)
throws PrinterException {

g.setFont(new Font("TimesRoman",Font.PLAIN,fontSize));
Graphics2D g2d = (Graphics2D)g;
g2d.translate(pf.getImageableX(), pf.getImageableY());

g.setColor(Color.BLACK);
g.drawString(lm.getLrDate(),140,65);
g.drawString(lm.getLrNumber(),200,65);


/* tell the caller that this page is part of the printed document */
return Printable.PAGE_EXISTS;
}


public String printing()
{
String result = null;
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(this);
boolean ok = job.printDialog();

if (ok) {
try {
job.print();
result="printed successfully";
} catch (PrinterException ex) {
result=ex.getMessage();

}
}
return result;
}

}
-------------------------------------------------------------------------------------------------------------------------------


please can any one help me.......

Thanks in advance......
11 years ago
Hai every one... thanks for your suggestion...
this is my code....
---------------------------------------------------------------------
------------------------------------------------
when i run this code the file is showing first and then printing...
i dont want to show the file....
Without showing the file. i want to print directly....
thanks in advance.

How to make this with out show file....

-Monicka Akilan
11 years ago
Hello every one..
Am strucking with printing textfile using java..
What the problem i faced is the printer neglected all the empty spaces .
i have to print that text as per in the document..
Can any one help me...


Thanks in advance....


My code is
-------------------------------------------------
package src;

import com.dao.dto.LrMasterDTO;
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.print.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.text.*;

/**
* Using JAVA to print simple text file to a printer
*/

public class LRPrint implements Printable {

static AttributedString myStyledText = null;


public static void main(String args[]) {
/**Location of a file to print**/
WriteText wt=new WriteText();
InvoiceText it=new InvoiceText();
// it.main();
wt.main();
String fileName = "D:/dddd.txt";

/**Read the text content from this location **/
String mText = readContentFromFileToPrint(fileName);

/**Create an AttributedString object from the text read*/
myStyledText = new AttributedString(mText);

printToPrinter();

}

/**
* This method reads the content of a text file.
* The location of the file is provided in the parameter
*/
private static String readContentFromFileToPrint(String fileName) {
String dataToPrint = "";

try {
BufferedReader input = new BufferedReader(new FileReader(fileName));
String line = "";
/**Read the file and populate the data**/
while ((line = input.readLine()) != null) {
dataToPrint += line + "\n";
}
} catch (Exception e) {
return dataToPrint;
}
return dataToPrint;
}

/**
* Printing the data to a printer.
* Initialization done in this method.
*/
public static void printToPrinter() {
/**
* Get a Printer Job
*/
PrinterJob printerJob = PrinterJob.getPrinterJob();

/**
* Create a book. A book contains a pair of page painters
* called printables. Also you have different pageformats.
*/
Book book = new Book();
/**
* Append the Printable Object (this one itself, as it
* implements a printable interface) and the page format.
*/
book.append(new LRPrint(), new PageFormat());
printerJob.setPageable(book);

/**
* Calling the printDialog will pop up the Printing Dialog.
* If you want to print without user confirmation, you can directly call printerJob.print()
*
* doPrint will be false, if the user cancels the print operation.
*/
boolean doPrint = printerJob.printDialog();

if (doPrint) {
try {
printerJob.print();
} catch (PrinterException ex) {
System.err.println("Error occurred while trying to Print: "
+ ex);
}
}
}

/**
* This method comes from the Printable interface.
* The method implementation in this class
* prints a page of text.
*/
public int print(Graphics g, PageFormat format, int pageIndex) {

Graphics2D graphics2d = (Graphics2D) g;
/**
* Move the origin from the corner of the Paper to the corner of the imageable
* area.
*/
graphics2d.translate(format.getImageableX(), format.getImageableY());

/** Setting the text color**/
graphics2d.setPaint(Color.black);
/**
* Use a LineBreakMeasurer instance to break our text into lines that fit the
* imageable area of the page.
*/
Point2D.Float pen = new Point2D.Float();
AttributedCharacterIterator charIterator = myStyledText.getIterator();
LineBreakMeasurer measurer = new LineBreakMeasurer(charIterator,
graphics2d.getFontRenderContext());
float wrappingWidth = (float) format.getImageableWidth();
while (measurer.getPosition() < charIterator.getEndIndex()) {
TextLayout layout = measurer.nextLayout(wrappingWidth);
pen.y += layout.getAscent();
float dx = layout.isLeftToRight() ? 0 : (wrappingWidth - layout
.getAdvance());
layout.draw(graphics2d, pen.x + dx, pen.y);
pen.y += layout.getDescent() + layout.getLeading();
}
return Printable.PAGE_EXISTS;
}

}

-------------------------------
please help me to find the problem
11 years ago
hi winston

i need to print a text file using Desktop class.
when i use that that file is first opening and then print..
but i no need to make that file visible to user.
how to hide that file..
11 years ago

Am new to this site..
I need to hide lastly opened file using java..
thanks
11 years ago