Announcement Announcement Module
No announcement yet.
How to getRealPath??? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to getRealPath???

    I hava Class

    public class FileUploadAction extends AbstractAction implements Serializable {

    protected Event doExecute(RequestContext rc) throws Exception {
    MultipartFile file = rc.getRequestParameters().getRequiredMultipartFile ("file");
    String fileName = null;
    InputStream inputStream = null;
    OutputStream outputStream = null;
    if (file.getSize() > 0) {
    try {
    inputStream = file.getInputStream();
    outputStream = new FileOutputStream("c:\\" +getRealPath+ file.getOriginalFilename());
    System.out.println("fileName:" + file.getOriginalFilename());
    int readBytes = 0;
    byte[] buffer = new byte[10000];
    while ((readBytes =, 0, 10000)) != -1) {
    outputStream.write(buffer, 0, readBytes);
    System.out.println("fileName:" + file.getOriginalFilename());
    } catch (IOException ex) {
    Logger.getLogger(FileUploadAction.class.getName()) .log(Level.SEVERE, null, ex);
    return error();
    rc.getFlashScope().put("file", new String(file.getBytes()));
    return success();
    } else {
    return error();
    and file Flow.xml

    <var name="fileUploadAction" class="supportiveLearning.service.FileUploadAction "/>
    <evaluate expression="userBean" result="flowScope.user" />


    <view-state id="fileupload" model="user">
    <transition on="save" to="fileupload">
    <evaluate expression="fileUploadAction.doExecute"
    result="" result-type=""/>
    <transition on="cancel" to="newPage"/>

    <view-state id="newPage">
    <!-- <transition on="book" to="main" />-->

    <subflow-state id="main" subflow="main-flow">


    and fileupload.xhml

    <form name="submitForm" method="post" enctype="multipart/form-data">
    <input type="file" name="file"></input>
    <td colspan="2"> </td>
    <td colspan="2" class="buttonBar">
    <input type="submit" name="_eventId_cancel" value="Cancel" />

    <input type="submit" name="_eventId_upload" value="Upload Photo" />
    I don't know how get getRealPath for image or *.doc. etc

    Everybody can help me!!!

    Thank you so much!