How to forward a page in jsp?

hi,
I have 5 button, Now i want to forward page when a user will click a button? my following code is for the action of a main form,,,,,,
<%
String action=request.getParameter("submit");
     if(action.equalsIgnoreCase("For dynamic form set")){
          RequestDispatcher rd =request.getRequestDispatcher("FrameSet.jsp");
          rd.forward(request,response);
     else if(action.equalsIgnoreCase("Data Read")){
          RequestDispatcher rd =request.getRequestDispatcher("DataReadForm.jsp");
          rd.forward(request,response);
     else if(action.equalsIgnoreCase("New Registration")){
          RequestDispatcher rd =request.getRequestDispatcher("NewRegistration.jsp");
          rd.forward(request,response);
     else if(action.equalsIgnoreCase("Continue from previous position")){
          RequestDispatcher rd =request.getRequestDispatcher("FrameSet.jsp.jsp");
//          RequestDispatcher rd =request.getRequestDispatcher("ContinuesForm.jsp");
          rd.forward(request,response);
     else if(action.equalsIgnoreCase("Frame Search")){
          RequestDispatcher rd =request.getRequestDispatcher("FrameSearch.jsp");
          rd.forward(request,response);
%>my problem is that ...when i click "For dynamic form set" button then it go FrameSet page, But when i click another button then my code is not working. What's the problem of my code? how i will forward a page in jsp . Is there anyone who can help me about this? Please help me.
With regards
Bina

you should get a value from the requested page to decide where to forward the next page.. example of forwarding a page:
<jsp:forward page="/page.jsp">

Similar Messages

  • How to forward a page from multiple frames

    hi,,
    in my first jsp page there are 4 frames header ,footer,one left frame and right frame
    in my header log out is there if im clicking logout it should forward to login page.it is happening but that page is coming within that header part(frame).how to make it visible as a full screen
    my first page containing frames is as follows
    <html>
    <frameset rows="15%,*" ,id="app_frame" borderColor="red" frameBorder="0" frameSpacing="0">
    <frame src="frame1.jsp" id="bar_top_frame" name="top_frame" marginWidth="0" marginHeight="0" scrolling="no"/>
    <frameset rows="89%,*",border="0" framespacing="1" frameborder="no" borderColor="red">
    <frameset cols="20%,75%",id="app_frame2" borderColor="#33CCFF" frameBorder="yes" frameSpacing="0" >
    <frame src="bar_left.jsp"id="bar_left_frame" name="bar_left_frame" marginWidth="0" borderColor="red" marginHeight="0" scrolling="no" />
    <frame src="frame3.jsp" id="work_frame" name="work_frame" marginWidth="0" borderColor="red" marginHeight="0" framespacing="1" />
    </frameset>
    <frameset rows="100%,*",border="0" framespacing="0" frameborder="0" borderColor="#0">
    <frame src="footer.jsp" name="footer" NORESIZE frameborder="0" scrolling="no"/>
    </frameset>
    </frameset>
    </frameset>
    </html>
    and my header frame that is frame1 is as follows
    <html>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>ALMAT_ROLE_MAINTAINENCE</title>
    <link href="<%=request.getContextPath()%>/almat/css/default.css" rel="stylesheet" type="text/css" />
    <body>
    <div id="header">
         <div id="topmenu">
              <ul>
                   <li>Home</li>
                   <li>Contact</li>
                   <li>Sitemap</li>
    <li><a href="<%=request.getContextPath()%>/almat/pages/jsp/firstPage.jsp accesskey="3" title="">Log Out</a></li>
              </ul>
         </div>
         <div id="logo">
              <h1>A L M A T</h1>
              <h2>..Allocation Made Easy</h2>
         </div>
    </div>
    </body>
    </html>
    pls help me out to solve this

    Simple answer is don't use Frames, Sorry I know you already have a design but plz! With JSP include there is no reason to use Frames also with the use of AJAX there is defo no need to use Frames.
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <div id="app_frame">
         <jsp:include page="/frame1.jsp" />
    </div>
    <div id="bar_left_frame">
         <jsp:include page="/bar_left.jsp" />
    </div>
    <div id="work_frame">
         <jsp:include page="/frame3.jsp" />
    </div>
    <div>
         <jsp:include page="/footer.jsp" />
    </div>PS, try using Javascript
    <script>
    document.location="/url"
    </script>Edited by: Gizard on Apr 17, 2009 6:54 AM

  • How to print a page in jsp?

    hello to every one...
    i made a report and when i click on print's link which is on my report page of jsp,a new popup window opens which show the report plus i want that when ever popup wndow open ,file->print... option should also be open..how can i do this?
    thanxs in advance...

    Hi
    You can open a new window, directing it to the report that you want to view. Also, call window.print() in your popup window.

  • How to call HTML page through JSP ?

    i want to know Hw to call Automaticly a HTML page through JSP.
    example :-
    have u seen yahoo login wen u put your ID & pass & Clock on login button it will chack ID & pass in the database & if it is correct then It will call A Mail Home Page.
    that's same i want to do.
    i have a jsp page which chacks the userID & Pass & call the first.html page
    but i dont know how to call html page automaticly.
    Any one can help me
    what i think is this
    tell me is it right or not
    suppose i have made a variable
    String add = "first.html"
    after chacking userID & pass
    if(idpass == true)
    add;
    if(idpass == false)
    erre;
    it will work or not pl tell me

    If you do the redirect with javascript, the user cannot resubmit his login when he presses the refresh button. When he does press refresh, he only refreshes the redirect, not the form post that was before it. When he presses back the redirect will also kick him back in stead of going back to the login page. A simple javascript redirect page would look like this:
    <html>
    <body onload="document.location.href='myhtmlpage.htm';">
    </body>
    </html>But that is only if you care about resubmits of course.

  • Help with how to forward the page from the serlet

    Hello,
    I previously post this page in a different place, sorry about that, however, i have small problem in forwarding servlet,
    here is my servlet class
    public class UploadTransferServlet extends HttpServlet {
             public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
              HttpSession session = request.getSession(true);
              UploadTransferForm uForm     = (UploadTransferForm)session.getAttribute("form");
              Session sess = null;
              try {
                   sess = Waterfind.getSessionFactory().openSession();
              } catch (net.sf.hibernate.HibernateException e) {
                   logger.error("Error opening hibernate session", e);
              try {
              } catch (Exception e) {
                   logger.error("Error adding image to the database", e);
                   try {
                        sess.close();
                   } catch (net.sf.hibernate.HibernateException ee) {
                        logger.warn("Exception closing session", ee);
              if (sess != null) {
                   try {
                        sess.close();
                   } catch (net.sf.hibernate.HibernateException e) {
                        logger.warn("Exception closing session");
              ServletContext servletContext = this.getServletContext();
              RequestDispatcher requestDispatcher = servletContext.getRequestDispatcher(uForm.getForward());
              logger.debug("forwarding " + uForm.getForward());
              requestDispatcher.forward(request, response);
         } // doPost
    } // ImageUploadand i do get forwarding /admin-add-trasnfer-form.html?formId=30402
    in my log f ile,
    however, in browser, it wouldnt forward to the page.. why is that?
    only half of the page load up, inc the html header,
    and address bar, it shows the servlet name.. not the actual page,
    how do i get to load the complete page,
    and is there is a way to update the actual page address in the address bar as well?

    i found the problem. its a jsp related problem, not wasnt getting the id, fixed it, thanks :)

  • How to forward a jsp page in flex application ( when a button is clicked)

    i am a fresher to this FLEX 2.0 , i designed the UI part in
    flex, but when i click the submit button it has to forward to the
    JSP page to check against the valid user,password , so how to
    forward the page to jsp(i mean from flex to jsp) , if u can suggest
    me with an example, it will be easy for me, is Flex Data Service 2
    is necessary for this
    thanks for ur speedy reply, hopping to get the solution for
    this issue,
    sandeep

    Your JSP is, as far as Flex is concerned, just a data service
    which it will request and read its response. I'd suggest using
    <mx:HTTPService>. For example:
    <mx:HTTPService id="authorize" url="validate.jsp"
    fault="handleFault(event)" result="handleResult(event)">
    <mx:request>
    <userid>{username.text}</userid>
    <password>{password.text}</password>
    </mx:request>
    </mx:HTTPService>
    Flex creates the request:
    http://{server}.{port}{context.root}/validate.jsp?userid=fred&password=flintstone
    assuming that you have <mx:TextInput id="username" />
    and <mx:TextInput id="password" /> components.
    Your Submit button then does: authorize.send()
    (note: you can also pass the request parameters in the send()
    method - check the Flex docs on HTTPService).
    Flex will listen for the response from your JSP. Typically a
    JSP would respond with an HTML page, but you don't want to do that
    for Flex. Your JSP should produce either a simple string ("yes" or
    "no" or "error" etc) or an XML document.
    The handleResult method can examine the response and do
    what's necessary.

  • How to forward an applet page to servlet/jsp?

    I have an applet in imageMap.jsp file. This applet displays a map. When user enters the page of imageMap.jsp, they will see the map . If user clicks a point of the map, the latitude and longitude of that point should be sent to Search.java servlet and search results should replace the current page.
    My Search.java servlet works well.
    I think I should add mouse event in the applet. I can use MouseEvent.getX() and MouseEvent.getY() in the applet to get latitude and longitude. But I do not know how to go from this applet to servlet. How can I forward applet page to servlet?

    The <jsp:plugin> action is used in pages to generate client specific HTML tags involving download and execution of the applet that is specified in the tag.

  • How can I forward next page, and then pop-up a download dialog box.

    My require is that pop-up a download dialog box after forwarding next page.
    I have read the coding in the processFormRequest of current page like below,
    but I find out that it only can pop-up a download dialog box,
    however, it can't forward the next page.
    pageContext.setForwardURL("OA.jsp?page=/oracle/apps/xxfm/fm002/webui/TEST001PG",
    null,
    OAWebBeanConstants.KEEP_NO_DISPLAY_MENU_CONTEXT,
    null,
    null,
    true,
    OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
    OAException.INFORMATION);
    //set default file name: [YYYYMMDDhhmm_IN.EXCEL,FILE_NAME.csv]
    StringBuffer strFileName
    = new StringBuffer().append((pageContext.getCurrentDBDate().toString().substring(0, 16))
    .replaceAll("-","").replaceAll(" ","").replaceAll(":",""))
    .append("_IN.").append(strExcelFileName).append(".csv");
    //give csv file content
    BlobDomain csvFileBlob = (BlobDomain)am.invokeMethod("createCsvFile");
    //setenv
    HttpServletResponse response
    = (HttpServletResponse)pageContext.getRenderingContext().getServletResponse();
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition", "attachment; filename="+strFileName.toString());
    System.out.println("fileName : "+strFileName.toString());
    //download
    InputStream fileIn = csvFileBlob.getBinaryStream();
    long fileLen = csvFileBlob.getBufferSize();
    int readBytes = 0;
    int totalRead = 0;
    byte blockgbyte[] = new byte[65000];
    response.setContentType("application/x-msdownload");
    response.setContentLength((int)fileLen);
    while((long)totalRead < fileLen)
    readBytes = fileIn.read(blockgbyte, 0, 65000);
    totalRead += readBytes;
    response.getOutputStream().write(blockgbyte, 0, readBytes);
    fileIn.close();
    response.getOutputStream().flush();
    I don't know what's matter in the app, can you tell me how to deal with it.
    Thanks in advance.

    Hi there,
    I have a similar requirement. User will download search results in a CSV file after which I want either the page to be refreshed or to be able to goto a Confirmation page or navigate to another page.
    I tried using setForwardURL / forwardImmediately / redirectImmediately methods as well as redirectToDialogPage. Since we use pageContext.setDocumentRendered(false); and response.getOutputStream().flush(); methods, the HttpResponse is already committed.
    Hence, the page does not redirect to another page as Request is processed and Response is complete. In case of methods like setForwardURL A JSP forward redirects the same request object to the target URL.
    Can anyone help here to achieve the expected requirement?
    Thanks.

  • How to use Session scope in jsp page

    Hello, I have login form, where user provides username and password. Then click on submit, it will forward to validation.jsp. Where it will check in database make sure username and password exit. Now i can also retrive accountid of perticular user. I want to put that username and accountid in session scope. so all other pages can use that username and accountid. How can i do that. I'm new at this, so please provide me example too. Here is my code for login.jsp and validation.jsp..
    Validation.jsp
    <%@ page import="java.util.*" %>
    <%@ page import="java.sql.*" %>
    //String name = request.getParameter( "username" );//
    //session.setAttribute( "accountID",accountID );//
    <%
    String connURL = "jdbc:oracle:thin:@orca.csc.ncsu.edu:1521:ORCL";
         Connection conn = null;
         Statement stmt = null;
         ResultSet rs = null;
    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    conn = DriverManager.getConnection(connURL, "vapatel","pjdas");
    stmt = conn.createStatement();
    String user=request.getParameter("userName");
    String password=request.getParameter("password");
    boolean entrance=false;
    stmt.excuteQuery("SELECT AccountID From Password WHERE USERNAME='"+user+"'");
    rs = stmt.executeQuery("SELECT * FROM Password WHERE USERNAME='"+user+"' AND PASSWORD='"+password+"'");
    while(rs.next()){
    String dbUser = rs.getString("USERNAME");
    String dbPassword= rs.getString("PASSWORD");
    if ((user.equals(dbUser)) && (password.equals(dbPassword))){
    entrance=true;
    if (entrance==true){%>
    <jsp:forward page="form.jsp"/>
    <%}
    else{%>
    <jsp:forward page="login.jsp"/>
    <%}
    %>

    hi,
    to put something into session scope in a jsp page use:
    session.setAttribute("counter", Integer.toString(5));to retrieve is from a jsp page use:
    String counterAttribute = (String)session.getAttribute("counter");

  • How to pass parameter to intro.jsp page ?

    Hi all,
    Anybody please tell me how to pass parameter to intro.jsp page.
    Is there any param name defined in <forward > syntax ?
    I have made following configuration in struts-config.xml file.
    I want to pass parameter to intro.jsp page
    <global-forwards>
              <forward name="invalidsession" path="/intro.jsp" redirect="true" />
    </global-forwards>
    please reply soon.
    Thanking you.

    Hi all,
    I have a similar kind of question..
    Iam trying to pass a string variable from JSP to servlet thro URL..
    Im using tomcat5
    COde:
    String fname=request.getParamter("filename");
    <jsp:forward page="/servlet/coreservlets.filedownload?name=" +fname />
    It is generating a unterminated tag error..Please help..

  • "How to forward from a struts form to a login page?"or "how to connect form

    Can Any boby please let me know
    "How to forward from a struts form to a login page?"or "how to connect form to login session id"?
    Thanks
    Shailajakrishna

    I believe I can not use a
    request.sendRedirectURL("....") in which I would
    encode all my parameters, because:Righto. This is a bit tricky.
    Basically, you have two options, and both of those are a little nasty.
    1) You could use and intermediate JSP page. Just dispatch you request to that page, use the attributes to construct a form with hidden fields, and use Javascript to POST that form to your intended URL on the document's BODY onload event. Would work, but wouldn't be pretty and requires you to use JSPs and Javascript. Still an idea.
    2) This is something that I wouldn't recommend. Open a socket to the URL you you want to post your data. Manually construct a HTTP POST request, encoding your parameters into the headers. Read and parse the response & modify your HttpServletResponse object accordingly.
    Take a look at i.e. http://javaalmanac.com/egs/java.net/PostSocket.html?l=new for some pointers.
    I'd go with item #1.
    For my own edification, I'd be also interested in
    knowing why such a function does not exist in the
    current httpServletRequest api.I suppose it's a little out of scope. Servlets were ment to interoperate inside one container, not across domains and different implementations.
    I'm guessing I must be missing something fundamentals
    maybe?No, you're not.
    .P.

  • How to print new line in jsp page

    hi
    how to print new line in jsp page
    thanks

    \n - new line character is in java specific not HTML
    specific.Well, if the correct line separator sequence (by far not always \n) would be used, it does add a new line to the HTML output. Too bad that you don't want to see HTML but formatted text. The BR tag is a formatting element for the displayed text, not a line break in HTML. ;)

  • 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

  • How to enable the EL in jsp page

    hi can u tell 'how to enable the EL in jsp page'?

    *I am getting below exception in tomcat when i inclued +<%@ page isScriptingEnabled="true" isELEnabled="true"%>+*
    org.apache.jasper.JasperException: /index.jsp(1,1) Page directive has invalid attribute: isScriptingEnabled
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
         org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:311)
         org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:106)
         org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:590)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2388)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2394)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
         org.apache.jasper.compiler.Validator.validate(Validator.java:1700)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:178)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

  • How to call BPEL process in JSP page

    Hi
    I am new to BPEL.please help me how to call BPEL process in JSP page.
    Thank You...

    Check this thread ....
    How can i call asyncronous BPEL process from Java Class????
    Tom..

Maybe you are looking for

  • Items could not be synced

    I'm using iTunes 10.5.1 for Mac OS X 10.6.x I see an error on my iPad and iPhone 4 that says "17 items could not be synced. See iTunes for more information" I can't see where to check which files the iPad/iPhone could not sync. In previous iTunes ver

  • Captivate 5 files not working in Atlantic link, help please

    Version Captivate 5 Published file swf Atlantic link's Content Point version 1.31 I've previously been using Captivate 4 and publishing swf files to be loaded in to Atlantic Link's Content Point.  To get the swf files to work in the past have publish

  • N97 doesn't go on after disconnected during update

    Hi, i wanted to update my n97 from 12 to version 2.0. During the update my phone disconnected and connected back to my computer while it was busy doing the update. This made the program flip a couple of times and in the end it said can't continue upd

  • Cant Open Print Dialog for Powerpoint in Firefox

    Whenever i try to print off Firefox, there will be a small box saying "preparing to print" (with a small spinning series of dots) that lasts for 3 seconds or less. Then the box will disappear and there will be a TINY box saying "javascript" at the ve

  • 2 iPhoto Libraries & Photo Stream

    I have two iPhoto libraries on one iMac. Is it possible to have a photo stream for each of those libraries on the shared iMac?