Redirecting to a jsp page inside 'init' method of a servlet

In the next example code, in case some Exception happens, I want to redirect the flow to some
JSP; How can I do that??
     public void init() {
          try {
               <some_code_block>
          } catch (Exception e) {
               //response.sendRedirect(response.encodeURL("/../somePage.jsp"));
               //'response' is not accesible here
     }thanks!

FLAGS are cool!
this is my solution:
public class MyServlet extends HttpServlet {
     boolean success;
     String exceptionMsg;
     public void init() {
          try {
               <some_code_block>
               success = true;
          } catch (Exception e) {
               success = false;
               exceptionMsg = e.getMessage();
     public void service (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          if (success) {
               <servlet_code_here>
          } else {
               response.sendRedirect(response.encodeURL("/somewhere/SomePage.jsp?exceptionMsg=" + exceptionMsg));
}.. thank for your reply!

Similar Messages

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • I have a button in JSP page inside an UIWebView by pressing the button i want to run another existing iPhone native application in background only.Do anyone have a solution for this.

    I have a button in JSP page inside an UIWebView by pressing the button i want to run another
    existing iPhone native application in background only.Do anyone have a solution for this.

    Sounds like a virus.... I hope it's not...
    Launching Other Apps within an iPhone

  • Forwarding to jsp page inside web-inf

    hi everyone,
    i have a question. i have jsp pages inside web-inf folder and i have welcome page of project(outside web-inf) in pages from where i want to give link to jsp page inside web-inf folder. this project is absed on spring framework. how can i do this?
    thanks in advance

    hi everyone,
    i have a question. i have jsp pages inside web-inf folder and i have welcome page of project(outside web-inf) in pages from where i want to give link to jsp page inside web-inf folder. this project is absed on spring framework. how can i do this?
    thanks in advance

  • SSO problem when redirecting from a JSP page to an external application

    Hi,
    I try to make a redirect from a JSP page (that is under a SSO protected application on iAS) to another page from another application, on an external iAS server, also protected by (a different) SSO. After the redirection is done, the login window appears, I enter the login name and the password and after that I obtain the followin error:
    "Oracle SSO Failure - Unable to process request
    Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
    Please notify your administrator."
    In the logs og the server I found the following:
    [OSSO] W05: Requested URL is not specified in terms of fully-qualified host name or invalid SSO partner configuration. Host from request
    mycompany.com:7777, registered host 144.147.147.200:7778.
    (the ip address being the address of the mycompany.com host).
    Any clue about this? Thanks a lot in advance!
    Regards,
    Marinel

    Hi Carlo,
    Thanks for your answer.
    The JSP original page is not added as a partner application to the second SSO server.
    The idea was that the user should insert first the login name/passwd for the first server, after being logged in, then redirected to the second application (on a different server), insert the login name/password for the second application and then load the 2nd application page. It seems that is not working after inserting the password for the 2nd application.
    Coming to a more general question that could help me to avoid this complicated approach: is it possible to have two different applications deployed on two different iAS servers and the two applications to use the same SSO (let's say the one from the first iAS server)? I have to mention that the process scenario is the following: the user load a page from the first application (protected by SSO), then, after successfull login and some processing in the first app, he will be automatically redirected by the first app to the second application, on the second server. I want to have also the second application, on the 2nd server, protected by SSO (ideally would be the same SSO as the first one!). Ideally the scenario would be: if it is redirected from the first app and the user is already authenticated, the automatic redirection should be done transparently for the user (without enetring the password again). If the user goes directly from the browser to a page of the second app, the SSO login window should be displayed and the user should provide his password.
    Is such a scenario possible on two apps deployed on two different servers?!
    Thanks a lot again!
    Regards,
    Marinel

  • Display jsp page inside tabset

    Hi
    I want to display different jsp pages inside different tab control of a particular tabset.I got a tabset with five tab controls.Also i got five jsp pages which i want to display inside each tab in the tabset. I tried to connect each page with a particular tab in PAGE NAVIGATION WINDOW.but when i am running the page,the tabs are not displaying the corresponding jsp pages.Anyone plz help me
    Thanks
    Shameer A

    Duplicate of http://swforum.sun.com/jive/thread.jspa?threadID=63106&tstart=0

  • How can i redirect to another JSP page automatically after some event

    I am developing a Tic-Tac-Toe game which can be played between two players who are on two different machines.
    When the first player comes to the Welcome page he will redirected to a Waiting Page when he clicks on the 'Start' button.
    When the second player comes to the Welcome page he will be redirected directly to the Game page, on clicking the 'Start' button.
    So how can i redirect the first player to the Game page after the second player is available for the game.
    And if i want to manage multiple instances of my game how can i do that//
    I am using JSP, javascript and MySQL for developing my project, and I am new to all these tools, but i would still like to carry on with all these only

    This is a bit of a challenge because of the nature of the web. Generally the web is "pull only" meaning that the browser has to initiate any interactions - the server can't push data to the browser if it wasn't asked to.
    The easiest way to solve this is using AJAX via JavaScript to periodically poll the server for any status changes. There are other ways (the Comet protocol is one) but they start to get a bit difficult and are still a bit new and not completely supported in a standards way. And to be honest they are still basically polling though in a more efficient way.
    Are you using a JavaScript framework? Most of the JavaScript frameworks that I've used have built in support for polling in the background. You'd have to have the JSP/servlet side be able to handle these polling requests from the browser and, when another person joins the game, the server indicates that and sends that back to the browser.
    As far as multiple instances I would have the server automatically pair up users as needed. So when the first player arrives he has to wait for another player. When the second player arrives a new game is created for those two players. Now a third player arrives and waits until a fourth player shows up. When player 4 joins another separate game is created. Presumably the conversation between the browser and the server will need to include a "game number" or other unique number so that the server can keep track of the games.

  • Does control comes back to servlet after redirecting to a jsp page.

    Hi
    I have a query on request dispatcher.
    I have redirected control to a jsp page in my java class as below.
    HttpServletRequest request=null;
         HttpServletResponse response=null;
         RequestDispatcher requestDispatcher = request.getRequestDispatcher("a.jsp");
         try {
              requestDispatcher.forward(request,response);
         } catch (ServletException e) {
              System.out.println("success");
              e.printStackTrace();
         } catch (IOException e) {
              System.out.println("success 1");
              e.printStackTrace();
         finally
              System.out.println("success 2");
         System.out.println("success 3");
         Jsp page is successfully diaplayed in browser.
    but when i see my console window in eclopse IDE...
    I does not diaply Success 2 / Success 3....
    Please help me..
    thanks

    This is an eclipse/server question... not really a java question.
    I have NO IDEA how eclipse interplays with you're (unspecified) server.
    I can tell you that typically the standard output and error streams of the J2EE server are redirected by the server startup script to a file in the deployed applications root directory... So have a look around.
    Edited by: corlettk on 16/05/2008 04:49 - Oops.

  • Redirecting across 2 jsp pages in 2 different servers

    hi, can anyone tell me if i can use redirect to automatically link from a page on 1 server to a page in another server, or is there some security concerns that will prevent the redirect function from working across 2 servers? thanks.

    oh thanks but can i pass a parameter to the jsp page residing in another server using redirect? e.g.
    response.sendRedirect("http://www.anotherserverpage.jsp?valuetopass=10");
    will i be able to use Response.getParameter in the page residing in the other server?

  • How to open a jsp page inside a portlet directly ,Cannot find FacesContext

    Hi
    Thank you for reading my post.
    I have a portlet (a jsf portlet build by JSC) , now i need to open a window that
    will show some information , i managed to open the pop-up and pass some parameters to popup
    but right now , i do not know what is my jsp file url
    as you know portlets are deployed diffrent than plain web jsf application.
    I find that if i use
    http://localhost:28080/Adv/viewMessageDetails.jsp?messageID=10
    it will open the page , but unfortunetly it return an error like :
    Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
    Exception Details: javax.servlet.jsp.JspException
    Cannot find FacesContext
    Possible Source of Error:
    Class Name: javax.faces.webapp.UIComponentTag
    File Name: UIComponentTag.java
    Method Name: doStartTag
    Line Number: 405
    Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.
    and some stack trace.
    how i can fix this problem ?
    thank you

    In portlet project, to navigate between pages, you should not use the URL property to link to a page. Instead, portlets use navigation via action handling. You use the Page Navigation editor to set up links to pages; that is, the navigation editor sets the action property.
    Here is an example to hyperlink ans button to open a new page:
    # From within the IDE, create a new portlet project. This action creates the project and one page, PortletPage1.jsp.
    # Create a second portlet page, called PortletPage2.jsp, for the project.
    # Drop a Hyperlink component onto the first portlet page, PortletPage1. (You can drop the Hyperlink on the page in the Design window or on the PortletPage1 node in the Outline window.) Change the Hyperlink's text property to Next Page.
    # Drop a Button component (found in the Basic section of the Palette) onto the second portlet page, PortletPage2.
    # Open the Page Navigation Editor. It displays the two pages (PortletPage1.jsp and PortletPage2.jsp) of the application.
    # Click the PortletPage1.jsp icon in the Navigation window to expand it, and then drag a connector from hyperlink1 to PortletPage2.jsp. Change the name of the connector from case1 to Page2.
    # Click the PortletPage2.jsp icon in the Navigation window to expand it, and then drag a connector from button1 to PortletPage1.jsp. Change the name of the connector from case1 to Page1.
    # Run and deploy the portlet. The browser displays PortletPage1 and you should see the Next Page hyperlink. When you click the Next Page hyperlink, the Apache Pluto Portal server displays PortletPage2. Click the Page2 button to return to PortletPage1.
    Sherry
    Creator Team

  • Redirect to the jsp page after user authenticated successfully  …

    Here is the requirement …
    I’m using “JAAS – Custom Login Module” for user authentication.
    I have few questions in Portal Logon process …
    1. Exactly at what point I can conclude that the user has been authenticated successfully, because I have to redirect the user to some other page for the first time logon to enter some information, subsequent logins shouldn’t be redirected. (I can update flag upon entering information).
    2. Where should I add my redirection code? Is it in my JASS Custom Login Module?
    If yes, how can I do that ? I’m more consider on “where should I add it”?
    3. Do I need to change my “UmLogonPage.jsp” to complete my requirement?
    4. Once after entering the Logon information, who will call my JASS – Custom Login Module for authentication? If authentication has failed who will return the control back to the “umLogonPage.jsp”?
    5. In my JASS Custom Login Module, I have no redirections except having logic for authentication process, and some Login Exceptions are thrown for failure logins.
    6. Who will catch these exceptions for failure logins to redirect back to the “umLogonPage.jsp”.
    7. Finally I like to know where can I add my redirection logic once the user has been authenticated successfully?
    8. last but not least can any of the experts explain the whole login process (using JASS module)? How the control goes from one component to another?
    Any kind of help is appreciated.
    Points can be awarded for useful answers.
    Thanks
    MMK

    Thanks a lot for your valuable reply.
    yes what you said was correct, storing information in R/3 System and getting the details from FM using Connector framework.
    You said i have to modify "header.jsp", can you please tell which .par file should i get to modify?
    one more question to you ... i have provide custom logon error messages to the user ... i did all the modification in logon.par and deployed in EP 6 .. working fine .. i can able to see "User ID Missing" , "Password Missing" etc ..
    when i place same peace of code in EP 7 it always displaying "User Authentication failed". can u guess what whould be the problem?
    Thanks
    MMK

  • Redirect to main jsp when the session expires

    Hi,
    I have a jsp say mainframe.jsp in which I have two frames each having a jsp page say child1.jsp and child2.jsp.
    When the session expires and I when i try do any changes in child2.jsp or child1.jsp, the page redirects to login page and when I login successfully, I am getting redirected to child2.jsp or child1.jsp respectively. But I want it to be redirected to mainframe.jsp.
    Any help is greatly appriciated.
    Thanks in advance.
    Vinod

    I think I am not clear.
    When I try to login after session expiry, I am redirected to child jsp.
    But what I want is that I should be redirected to mainfram.jsp page.
    url in the address shows : ../mainframe.jsp?ID=******
    When my seesion is expired and I try do some manipulation in child1.jsp (which is inside a frame of my mainframe.jsp). it is redirected to login page and from there to child1.jsp instead of mainframe.jsp
    Now the address url shows : ../child1.jsp?ID=********* because of which I am not able to see child2.jsp along with child1.jsp
    What I want : ../mainframe.jsp?ID=********
    this is the code I am using !!
    String destPage = request.getRequestURI();
    response.sendRedirect("../redirect.jsp?dest=" + URLEncoder.encode(destPage));

  • How can I Locate the correct filepath in a jsp page?

    In http://localhost:8080/myweb/a.jsp, I will call a java bean file which is locate in http://localhost:8080/myweb/WEB-INF/classes/haha/DBConnection.class. This java file requires to read an external file which locates in http://localhost:8080/myweb/WEB-INF/classes/haha/db.txt
    My question is how can I get the correct filepath in this environment?
    inputStream = new BufferedReader(new FileReader(????????));
    Only this will work
    inputStream = new BufferedReader(new FileReader("D:\Program Files\Apache Software Foundation\Tomcat 5.5\db.txt"));
    But no one will place the file here, and it is impossible to do this when upload to 3rd party hosting.
    Any suggestion? thx.

    Thx all, in a jsp page, calling this method is fine.
    ServletContext s = getServletContext();
    String a = s.getRealPath("/");
    In a Servlet file, below method is ready to use:
    String b = getServletConfig().getServletContext().getRealPath("/");
    My problem is, I have a jsp page, which initialize a java bean , this java file is responsible for Database Connection, which will read the external text file to get the login, password and database name. So I won't need to recompile this file every time when I place in different platform with different configuration. I only need to edit the text file is ok.
    But How can I get the absolute file path when that jsp page initialize that java bean file? Below is my error, any suggestions are thx.
    package sql;
    import java.sql.*;
    import java.util.ArrayList;
    import java.io.FileReader;
    import java.io.BufferedReader;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class DBConnection extends HttpServlet{
    public String sql = null;
    public Connection con = null;
    public Statement statement = null;
    public ResultSet rs = null;
    private BufferedReader inputStream = null;
    private static ArrayList<String> arr = new ArrayList<String>();
      public DBConnection(){
        String fs = System.getProperty("file.separator");
        ServletContext s = getServletContext();
        String realpath = s.getRealPath("/");
        String filepath = realpath + "WEB-INF"+fs+"Properties"+fs+"db.txt";
        try{
          inputStream = new BufferedReader(new FileReader(filepath));
          String l;
          while ((l = inputStream.readLine()) != null) {
            arr.add(l);
          Class.forName("com.mysql.jdbc.Driver");
          this.con = DriverManager.getConnection("jdbc:mysql://localhost:3306/"+arr.get(0)+"?user=" +arr.get(1)+ "&password="+arr.get(2)+"&useUnicode=true&characterEncoding=utf-8");
          this.statement = this.con.createStatement();
        }catch (Exception e){
          System.err.println(e.getMessage());
        }finally{
    }java.lang.NullPointerException
         javax.servlet.GenericServlet.getServletContext(GenericServlet.java:159)
         sql.DBConnection.<init>(DBConnection.java:20)
         html.ShowCategory.<init>(ShowCategory.java:17)
         org.apache.jsp.left_jsp._jspService(left_jsp.java:66)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

  • Combine two jsp pages into single

    hai how to combine two jsp pages in to one
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;
    import org.apache.struts.action.ActionMessages;
    import com.latchiya.Constants;
    import com.latchiya.model.Staffinfo;
    import com.latchiya.service.Manager;
    import com.latchiya.webapp.form.StaffinfoForm;
    * Action class to handle CRUD on a Staffinfo object
    * @struts.action name="staffinfoForm" path="/staffinfos" scope="request"
    * validate="false" parameter="method" input="mainMenu"
    * @struts.action name="staffinfoForm" path="/editStaffinfo" scope="request"
    * validate="false" parameter="method" input="list"
    * @struts.action name="staffinfoForm" path="/saveStaffinfo" scope="request"
    * validate="true" parameter="method" input="edit"
    * @struts.action-forward name="edit" path="/WEB-INF/pages/staffinfoForm.jsp"
    * @struts.action-forward name="list" path="/WEB-INF/pages/staffinfoList.jsp"
    * @struts.action-forward name="search" path="/staffinfos.html" redirect="true"
    public final class StaffinfoAction extends BaseAction {
    public ActionForward cancel(ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {
    return mapping.findForward("search");
    public ActionForward delete(ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {
    if (log.isDebugEnabled()) {
    log.debug("Entering 'delete' method");
    ActionMessages messages = new ActionMessages();
    StaffinfoForm staffinfoForm = (StaffinfoForm) form;
    // Exceptions are caught by ActionExceptionHandler
    Manager mgr = (Manager) getBean("manager");
    Staffinfo staffinfo = (Staffinfo) convert(staffinfoForm);
    mgr.removeObject(Staffinfo.class, staffinfo.getStaffId());
    messages.add(ActionMessages.GLOBAL_MESSAGE,
    new ActionMessage("staffinfo.deleted"));
    // save messages in session, so they'll survive the redirect
    saveMessages(request.getSession(), messages);
    return mapping.findForward("search");
    public ActionForward edit(ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {
    if (log.isDebugEnabled()) {
    log.debug("Entering 'edit' method");
    StaffinfoForm staffinfoForm = (StaffinfoForm) form;
    // if an id is passed in, look up the user - otherwise
    // don't do anything - user is doing an add
    if (staffinfoForm.getStaffId() != null) {
    Manager mgr = (Manager) getBean("manager");
    Staffinfo staffinfo = (Staffinfo) convert(staffinfoForm);
    staffinfo = (Staffinfo) mgr.getObject(Staffinfo.class, staffinfo.getStaffId());
    staffinfoForm = (StaffinfoForm) convert(staffinfo);
    updateFormBean(mapping, request, staffinfoForm);
    return mapping.findForward("edit");
    public ActionForward save(ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {
    if (log.isDebugEnabled()) {
    log.debug("Entering 'save' method");
    // Extract attributes and parameters we will need
    ActionMessages messages = new ActionMessages();
    StaffinfoForm staffinfoForm = (StaffinfoForm) form;
    boolean isNew = ("".equals(staffinfoForm.getStaffId()) || staffinfoForm.getStaffId() == null);
    Manager mgr = (Manager) getBean("manager");
    Staffinfo staffinfo = (Staffinfo) convert(staffinfoForm);
    mgr.saveObject(staffinfo);
    // add success messages
    if (isNew) {
    messages.add(ActionMessages.GLOBAL_MESSAGE,
    new ActionMessage("staffinfo.added"));
    // save messages in session to survive a redirect
    saveMessages(request.getSession(), messages);
    return mapping.findForward("search");
    } else {
    messages.add(ActionMessages.GLOBAL_MESSAGE,
    new ActionMessage("staffinfo.updated"));
    saveMessages(request, messages);
    return mapping.findForward("edit");
    public ActionForward search(ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {
    if (log.isDebugEnabled()) {
    log.debug("Entering 'search' method");
    Manager mgr = (Manager) getBean("manager");
    request.setAttribute(Constants.STAFFINFO_LIST, mgr.getObjects(Staffinfo.class));
    return mapping.findForward("list");
    public ActionForward unspecified(ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {
    return search(mapping, form, request, response);
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.upload.FormFile;
    import com.latchiya.Constants;
    import com.latchiya.webapp.form.UploadForm;
    * This class handles the uploading of a resume (or any file) and writing it to
    * the filesystem. Eventually, it will also add support for persisting the
    * files information into the database.
    * <p>
    * <i>View Source</i>
    * </p>
    * @author Matt Raible
    * @struts.action name="uploadForm" path="/uploadFile" scope="request"
    * validate="true" input="failure"
    * @struts.action-forward name="failure" path="/WEB-INF/pages/uploadForm.jsp"
    * @struts.action-forward name="success" path="/WEB-INF/pages/uploadDisplay.jsp"
    public class UploadAction extends Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {
    // Did the user click the cancel button?
    if (isCancelled(request)) {   
    request.removeAttribute(mapping.getAttribute());
    return (mapping.findForward("mainMenu"));
    //this line is here for when the input page is upload-utf8.jsp,
    //it sets the correct character encoding for the response
    String encoding = request.getCharacterEncoding();
    if ((encoding != null) && (encoding.equalsIgnoreCase("utf-8"))) {
    response.setContentType("text/html; charset=utf-8");
    UploadForm theForm = (UploadForm) form;
    //retrieve the name
    String name = theForm.getName();
    //retrieve the file representation
    FormFile file = theForm.getFile();
    //retrieve the file name
    String fileName = file.getFileName();
    //retrieve the content type
    String contentType = file.getContentType();
    //retrieve the file size
    String size = (file.getFileSize() + " bytes");
    String data = null;
    String location = null;
    // the directory to upload to
    String uploadDir =
    servlet.getServletContext().getRealPath("/resources") + "/"
    + request.getRemoteUser() + "/";
    //write the file to the file specified
    File dirPath = new File(uploadDir);
    if (!dirPath.exists()) {
    dirPath.mkdirs();
    //retrieve the file data
    InputStream stream = file.getInputStream();
    //write the file to the file specified
    OutputStream bos = new FileOutputStream(uploadDir + fileName);
    int bytesRead = 0;
    byte[] buffer = new byte[8192];
    while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
    bos.write(buffer, 0, bytesRead);
    bos.close();
    location = dirPath.getAbsolutePath()
    + Constants.FILE_SEP + file.getFileName();
    //close the stream
    stream.close();
    // place the data into the request for retrieval on next page
    request.setAttribute("friendlyName", name);
    request.setAttribute("fileName", fileName);
    request.setAttribute("contentType", contentType);
    request.setAttribute("size", size);
    request.setAttribute("data", data);
    request.setAttribute("location", location);
    //destroy the temporary file created
    file.destroy();
    //return a forward to display.jsp
    return mapping.findForward("success");
    ===========================================================================================
    i want to get second jsp file ie upload file to student file
    if anybody know please tell i am new to java side
    regards
    ranga

    ur not able to give solution
    insted giving comment mind ur words being in software fied
    commentting like bad words not good i warn u mind ur words

  • Logon Par - redirect to new JSP

    Hi,
    I've to change the portal logon page.
    My requirement is to redirect the logon page to test.jsp page.
    from umLogonPage.jsp i'm trying to redirect to test.jsp in form method.
    <FORM name="logonForm" method="post" action=test.jsp>
    but the URL is not proper.
    How can i pass the absolute URL for this.
    Thanks and Regards
    Puneet

    Puneeth,
    Its possible to  redirect to a JSP page from portal logon Screen.
    There are several ways of doing this:-
    1. Create a separate portal component (JSP Dynpage) and set the authscheme property is anonymous (because you are calling a portal component from outside) ie.
    <property name="AuthScheme" value="anonymous" />
    You can follow this method If JSP componentu2019s functionality is Independent than any login functionality.
    2. You can modify the SAPMLogonLogic.java file which contains flow logic of all jsp files. The SAPMLogonLogic file is present umelogonbase.jar.
    The umelogonbase.jar is under lib folder of the logon par file. Just extract the logon par file and navigate to PORTAL-INF -> lib to get the umelogonbase.jar
    Ram

Maybe you are looking for

  • Java Program - Forecast

    Can anyone help? Below is my program and I am getting 1error message when compiling and I can't figure it out. * WeatherForecast.java * Created on November 7, 2006, 9:38 AM * To change this template, choose Tools | Template Manager * and open the tem

  • Calculating...Until Full?????

    I just came up to turn on my iBook and the charging light is orange. I leave it plugged in all the time so I know it didn't need to charge. I checked the charging status and it says "Calculating...Until Full" but the charge percent is 100%. I unplugg

  • Mail deletion

    Before I installed ios7 I used to be able to delete individual mails on my oPhone by swiping to the right in the mailbox window. A red delete button would then appear. Can't seem to do this now - anybody know whether that facility has been lost?

  • Photos from iphoto 11 won't upload to fb

    Each time I try to share photos on fb it looks like it is uploading but then I get an error message.  It happens if I start in iphoto or in fb.  I can upload photos fine from my itouch, just not from my desktop.  It's been going on for a few weeks no

  • Find if string contain letters

    HI All, How can I find if in string contain lettesr (in all the languages ),for instance if lv_string = '1a11'. subrc = 0. if lv_string = 'aaaa'. subrc = 0. if lv_string = '1111'. subrc = 4. Best regards Joy Moderator Message: FAQ. Thread locked. Edi