JSP forward *HELP*

Hi,
Im trying to forward a JSP page to another if user password is blank,,
the code is :
errorString rURL = "myURL";
if (Pass.length() == 0){response.sendRedirect(rURL);}  but I get the following error:
HTTP Status 500 - Internal Server Error
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Cannot forward after response has been committed
     at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
     at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
     at org.apache.jsp.mainController_jsp._jspService(mainController_jsp.java:52)
     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
Can you please help me..

Try it like this:
if (Pass.length() == 0){
  response.sendRedirect(rURL); 
  return;
} Basically after you redirect/forward from your servlet, you should make sure the execution leaves your servlet/jsp page. Otherwise your page will keep adding to the output, which may result in this sort of error - particularly if it tries to forward/redirect to another page.
if (test){
  response.sendRedirect(...);
  return;
}or
if (test){
  response.sendRedirect(...);
else {
}

Similar Messages

  • JSP forwarding (Help!)

    After forwarding control to another JSP page or servlet using the RequestDispatcher.forward() method, can the response be modified once the forward method returns? For example,
    <%
    RequestDispatcher rd = request.getRequestDispatcher("/somepath");
    rd.forward(request, response);
    response.getWriter().println("Some more output");
    %>

    After forwarding control to another JSP page or
    servlet using the RequestDispatcher.forward() method,
    can the response be modified once the forward method
    returns? For example,
    <%
    RequestDispatcher rd =
    request.getRequestDispatcher("/somepath");
    rd.forward(request, response);
    response.getWriter().println("Some more output");
    %>Give it a try and see. Or see what The API might have to say about it...

  • Need code help in jsp:forward ... /

    Can any one give a little code as to how am i suppose to redirect my jsp execution with <jsp:forward../> tag.
    Give a little code of JSP file. i have tried with 2-3 examples but i could not do it. Certainly some wizard will help me doing this.
    Thanx in advance.
    husami

    its fine. i have understood your code. i have even tested with param attribute.
    Earlier i was using JWS2.0 now i have shifted to tomcat. it gives me problem to run jsp file. what could be the reason? servlets are running fine.
    is there any path or classpath setting probs
    or do i have to execute some other files of tomcat
    or do i have to use jspc with some options?.......
    please help
    husami

  • Help!!!why the flag " jsp:forward" don't work?

    the code like this:
    <%@page buffer="none" autoFlush="true" %> //attention: buffer="none"
    <%
    long i=0;
    for(i=0;i<10;i++)
    out.println("@@@@@@@@@@@@@@@@@");
    %>
    <jsp:forward page="test.jsp" />
    but it not turn to the page "test.jsp".Why?

    but it not turn to the page "test.jsp".Why? because of your page buffer being none.
    According to the API:
    forward should be called before the response has been committed to the client (before response body output has been flushed). If the response already has been committed, this method throws an IllegalStateException. Uncommitted output in the response buffer is automatically cleared before the forward.
    Having a buffer of "none" means that any output you do is sent immediately, and is committed. So you can't forward/redirect after you start output.
    Solution: give the page a buffer. Remove that page directive, and it should work.
    Cheers,
    evnafets

  • Help with JSP Forward !!!

    I have 3 pages ...1) index.jsp 2) Forward.jsp 3) welcome.jsp
    I have 2 fields in the index.jsp once upon filling & hit submit it has to to go Forward.jsp page...in the Forward.jsp..i have coded only one tag with
    <jsp:forward page="welcome.jsp" />
    I have one question...once the page comes to Forward page...will it display the contents of the Welcome .jsp in the same page itself...or it will go to Welcome.jsp page..
    As i saw it will display the contents of Welcome.jsp page in itself...
    Please let me know...
    Regards
    Gnanesh

    I understand your question only because I have a set up totally identical to yours. The thread Matt suggested does explain the situation (i.e. the server passed control to another page but the client doesn't know that), but doesn't necessarily give a good solution a problem that you may have, and that I do have:
    If the user sees the welcome page, and for some reason decides to "reload", the forward page is re-executed, even though it has done its job. This could be a problem for session management if you specifically don't want that job being done twice in a session. Now you could hack around that, but I'd really rather see a neat solution. Is there one?

  • Jsp:forward problem, help appreciated

    hi all,
    The following piece of code from a jsp page is giving the following error
    "java.lang.IllegalStateException: Error: Attempt to clear a buffer that's already been flushed".
    updateToCompAccount is a button on the previous page
    <%
    if(request.getParameter("updateToCompAccount")!=null){
    %>
    <jsp:forward page="UpdateToCompAccount.jhtml" />
    <% } %>
    here is the stack trace:
    java.lang.IllegalStateException: Error: Attempt to clear a buffer that's already been flushed
    at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:376)
    at org.apache.jsp.adminUserProfileUpdate_jhtml._jspService(adminUserProfileUpdate_jhtml.java:474)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
    at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:409)
    at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:528)
    at java.lang.Thread.run(Thread.java:595)
    Anybody have any ideas?
    Thanks.

    Well, the simplest way to do this would be:
    public class MyClass extends HttpServlet {
      public void doGet(HttpServletRequest request, HttpServletResponse response) {
           String buttonName = request.getParameter("myButtonRequestVariable");
           if ("update".equals(buttonName)) {
               request.getRequestDispatcher("UpdateToCompAccount.jhtml").
                             forward(request, response)
             } else if ("delete".equals(buttonName)) {
                  request.getRequestDispatcher("DeleteCompAccount.jhtml").
                            forward(request, response)
             } else {
                  request.getRequestDispatcher("ErrorPage.jhtml").
                      forward(request, response)
      public void doPost(HttpServletRequest request,
    } But that can get unwieldy if you've loads of buttons. Have you studied the concept of Model View Controller (MVC)?

  • Is the jsp forward tag fails in iplanet application server sp2?

    11/Feb/2002 17:55:41:2] error: Exception: SERVLET-compile_failed: Failed in compiling template: /EinsWebTool/QueryScreen.jsp, Parse error in JSP parser. Missing endtag: /jsp:forward
    Exception Stack Trace:
    java.lang.Exception: Parse error in JSP parser. Missing endtag: /jsp:forward
    at java.lang.Throwable.fillInStackTrace(Native Method)
    at java.lang.Throwable.fillInStackTrace(Compiled Code)
    at java.lang.Throwable.<init>(Compiled Code)
    at java.lang.Exception.<init>(Compiled Code)
    at com.netscape.jsp.JSP.parseBlock(Compiled Code)
    at com.netscape.jsp.JSP.parseReqDisp(Unknown Source)
    at com.netscape.jsp.JSP.parseTag(Compiled Code)
    at com.netscape.jsp.JSP.parseNext(Compiled Code)
    at com.netscape.jsp.JSP.parseBlock(Compiled Code)
    at com.netscape.jsp.JSP.parse(Unknown Source)
    at com.netscape.jsp.JSP.compile(Unknown Source)
    at com.netscape.server.servlet.jsp.JSPCompiler.JSPtoJava(Unknown Source)
    at com.netscape.server.servlet.jsp.JSPCompiler.compileJSP(Compiled Code)
    at com.netscape.server.servlet.jsp.JSPCompiler.compileOrLoadJSP(Unknown Source)
    at com.netscape.server.servlet.jsp.JSPCompiler.compileInstance(Unknown Source)
    at com.netscape.server.servlet.jsp.JSPCompiler.compileInstance(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callJspCompiler(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUriRestrictOutput(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformRequestDispatcher.forward(Unknown Source)
    at com.netscape.jsp.PageContextImpl.forward(Unknown Source)
    at jsp.APPS.EinsWebTool.Login._jspService(Compiled Code)
    at jsp.APPS.EinsWebTool.Login.service(Login.java:42)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.callJSP(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callJspCompiler(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUriRestrictOutput(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformRequestDispatcher.forward(Unknown Source)
    at com.netscape.server.servlet.jsp.JSPRunner.service(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.execute(Compiled Code)
    at com.kivasoft.applogic.AppLogic.execute(Compiled Code)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at com.kivasoft.thread.ThreadBasic.run(Compiled Code)
    at java.lang.Thread.run(Compiled Code)

    Hi,
    Yes, I was able to code this sucessfully and got it working. Here is the code I used...
    <%
    String fortune = (String) request.getAttribute("fortune_string");
    %>
    <HTML>
    <HEAD><TITLE>Fortune Sample Application</TITLE></HEAD>
    <BODY BGCOLOR=#FFFFFF>
    <H2>The Oracular Servlet greets you!</H2>
    <p>
    Your fortune is...
    <%= fortune%>
    <p>
    <p>
    <hr size=0>
    <p>
    <FONT SIZE=2>Sample Applications
    <jsp:forward page="/ias-samples/index.html">
    </jsp:forward>
    </BODY>
    </HTML>
    and I got it working. I believe the code is missing some tag, which I tried, but got error in KJS like...
    [15/Feb/2002 11:23:49:7] info: --------------------------------------
    [15/Feb/2002 11:23:49:7] info: jsp.APPS.fortune.fortune: init
    [15/Feb/2002 11:23:49:7] info: --------------------------------------
    Null text data??
    2002-02-15 11:24:16 - error-the file '\fortune.jsp' generated the following pars
    e exception: org.apache.jasper.compiler.ParseException: C:\iplanet\ias6\ias\APPS
    \fortune\fortune\fortune.jsp(17,0) Expected "param" tag with "name" and "value"
    attributes after the "params" tag.
    In your case, I suspect, either the parser is not able to convert the .jsp file appropriately, or some inappropriate tag. If this doesn't help please send me your code & I can help you on this regard.
    Regards
    Raj
    [email protected]

  • How to use TARGET in jsp:forward ???

    In a link I can use TARGET to display the page in another frame like this:
    <a href="http://localhost:8080/cars/Menu.jsp TARGET=FrameRight>Counties</A>
    Is it possible to do something similar when forwarding a page with the jsp:forward standard action??
    <jsp:forward page=SomePage" /">Would help me out if it was possible.</a>

    No. It is not possible, '<jsp:forward' is not meant for opening the page in a said location. It simply forwards the request to the target jsp. Then your taget JSP will take care of resonding to the request.
    If you want to open the page (jsp) in another frame, just stick on to the anchor tag and append your query string to the target jsp.
    <% String query = "?name=xxx&age=30&dept=22"; %>
    <a href="Target.jsp<%=query%> target="frameright">Counties</a>
    Sudha

  • Problem in jsp:forward

    hi,
    i have a jsp page from where i have to call my servlet.but it is mapped in xml by other name.so what should i do?can i call that servlet using named mapped into the xml.
    can i do this?
    <jsp:forward page="/servlet/web.xml mapping"></jsp:forward>
    it's urgent.
    so please help me.
    kamlesh solanki

    hey man,
    how u doin?
    your problem is quite funny. here in servlet configuration in the xml file there is what we call servlet mapping<servlet-mapping>.
    here is how we map a servlet to a kind of url:
    <servlet-mapping>
    <servlet-name>
    havet
    <servlet-name>
    <url-pattern>
    /havva.jspa
    </url-pattern>
    </servlet-mapping>
    nbow when calling this servlet using this url pattern it now behaves as if its in the main application directory just like where jsps are so u will forward to it like a jsp.
    thats the shizzy.
    ok call it like this now
    <jsp:forward page="havva.jspa" />
    or
    <jsp:forward page="havva.jspa"></jsp:forward>
    since u may be used to this style of calling the tag.
    stay cool and let me know if u had any problems.

  • Problem using jsp:forward in java script

    hi,
    when I use jsp forward tag inside java script i'm getting a problem that
    when the jsp is invoked it is getting forwarded to the page specified in the forward tag, without checking the if conditions. Following code may give you a better idea.
    <html>
    <script>
    function test()
    if(document.f.htemp.value=="true")
    alert("jus");
    else
    var s=document.f.htemp.value;
    alert(s);
    <jsp:forward page="success.jsp" />
    </script>
    <body>
    <form name="f" method=post>
    <input type=text name=htemp value="true">
    <input type=button onclick="test()">
    </form>
    </body>
    </html>
    please help me,thanks inadvance
    regards
    chandu

    What pgeuens means is that you can't mix javascript and jsp/java code in this way.
    ALL of the jsp/java code gets executed at the server end.
    This produces an HTML page (with embedded javascript) which gets sent to the client.
    The client then runs javascript code in response to events (onLoad, onClick, onChange etc etc)
    So in this case, the jsp:forward will always be executed, because as far as the server is concerned, the javascript is just template text.
    If you WANT to do a conditional forwarding on the server side you do it in java ie (horribly using scriptlet)
    <%
    if (testCondition){
    %>
      <jsp:forward>
    %<
    %>Or if you want to test what the client has entered client side, all you can do is submit the form, or navigate to a URL
    <script>
    function test()
    if(document.f.htemp.value=="true")
    alert("jus");
    else
    var s=document.f.htemp.value;
    alert(s);
    document.f1.action="success.jsp";
    document.f.submit();
    </script>You cannot run JSP code based on your javascript code.
    Java. Javascript. Not the same thing.
    Hope this helps,
    evnafets

  • Jsp:forward URL problem

    Hi,
    I have 2 pages X.jsp and Y.jsp
    The content of X.jsp is a simple
    // send an email here
    <jsp:forward page="Y.jsp">
    </jsp:forward>
    The content of Y.jsp is only "Mail is sent" message.
    The problem is that everytime page X is loaded,
    the browser displays Y.jsp content, but the URL in the Address box of the browser still displays X.jsp
    This leads me to reload problem, even though the page displays the "Mail is sent" message, the URL still shows X.jsp, and everytime the browser is reloaded, another mail is sent.
    How to make the URL change to Y.jsp ?
    TIA.

    Hi,
    I have 2 pages X.jsp and Y.jsp
    The content of X.jsp is a simple
    // send an email here
    <jsp:forward page="Y.jsp">
    </jsp:forward>
    The content of Y.jsp is only "Mail is sent" message.
    The problem is that everytime page X is loaded,
    the browser displays Y.jsp content, but the URL in the
    Address box of the browser still displays X.jsp
    This leads me to reload problem, even though the page
    displays the "Mail is sent" message, the URL still
    shows X.jsp, and everytime the browser is reloaded,
    another mail is sent.
    How to make the URL change to Y.jsp ?
    TIA.Thats the natural behavious of forward.
    One simple solution is not to use forward. You can use HTTP redirection rather than forward.
    Hope it helps.

  • Jsp forward problem, I think.....

    I have a default.htm page that takes in a feild, EMP_NUM. Once the user
              hits the Submit button, I run a select statement(select.jsp) to see if that
              number exists. If it does then I forward the contents to correct.jsp, if the
              number doesn't exist then I forward to failed.jsp.
              Today is Tuesday, and last Friday I was working on this and everything
              worked fine, in fact perfect. I came in this morning to do some more
              testing, specifically catching errors in my try and catch, example - to make
              sure they enter in a number, and after I type in a number and hit the submit
              button, it trys to go to the next page, but displays nothing, the page is
              blank. Where has before, when everything was working fine on Friday, my
              correct.jsp page or my failed.jsp page would be displayed.
              From Friday to Tuesday I had not made any changes to my files. The only
              thing different, that I can think of, would be that on Friday I would have
              stoppped weblogic and this morning I started weblogic again. This is why I
              think this is a weblogic issue or syntax on my part. I have tried to restart
              my computer, restart weblogic, and I even deleted the .java files that
              weblogic creates and places in the weblogic/myserver/classfiles/jsp_servlets
              folder.
              Below is my source code.
              Please help!
              Thanks, jl.
              <% try {
              <%@ include file = "db_conn.jsp"%>
              <%
              // A Statement object is what sends your SQL statement to the db
              Statement stmt = conn.createStatement();
              // Retrieve the user id number from the previous form.
              int EMP_NUM = Integer.parseInt(request.getParameter("EMP_NUM"));
              //SQL prepared statement
              String selectEMP_NUM = "SELECT NAME, COMPANY_KEY FROM WTS_PROFILE WHERE
              EMP_NUM=?";
              PreparedStatement psEMP_NUM = conn.prepareStatement(selectEMP_NUM);
              psEMP_NUM.setInt(1, EMP_NUM);
              ResultSet rsEMP_NUM = psEMP_NUM.executeQuery();
              String NAME = "";
              int CompanyKey = 0;
              while (rsEMP_NUM.next()) {
              NAME = rsEMP_NUM.getString("NAME");
              CompanyKey = rsEMP_NUM.getInt("COMPANY_KEY");
              }// end of while
              psEMP_NUM.clearParameters();
              psEMP_NUM.close();
              conn.close();
              String sEMP_NUM = Integer.toString(EMP_NUM);
              String sCompanyKey = Integer.toString(CompanyKey);
              if (NAME.equals("")) {
              request.setAttribute("EMP_NUM", sEMP_NUM);%>
              <jsp:forward page="failed.jsp">
              <% }// end of if
              else {
              request.setAttribute("NAME", NAME);
              request.setAttribute("EMP_NUM", sEMP_NUM);
              request.setAttribute("CompanyKey", sCompanyKey);%>
              <jsp:forward page="creditcard.jsp">
              <% }// end of else
              }// end of try1
              catch(Exception e) {
              <% if(e.toString().equals("java.lang.NumberFormatException: ")) { %>
              <font face="Arial" size="2" color="red"><center><strong>Please enter in a
              EMPLOYEE ID NUMBER.<br><br></strong></font></CENTER>
              <%}// end of if
              %>
              </TD></TR></TABLE></DIV>
              <font color="red">"<%=e.toString()%>"</font>
              <%
              }// end of catch1
              %>
              

              Sounds like you have some debugging to do. If you didn't reinstall WLS and it worked fine before,
              then I doubt it is a WLS problem.
              Is your page really blank? Try show source in your browser? I think you have some mismatched
              <table> </table>. Try it in both IE and Netscape - one of them forgives you for mismatched table
              tags.
              Add some System.out.println() in your code to see what is being executed.
              "james lorenzen" <[email protected]> wrote:
              > I have a default.htm page that takes in a feild, EMP_NUM. Once the user
              >hits the Submit button, I run a select statement(select.jsp) to see if that
              >number exists. If it does then I forward the contents to correct.jsp, if the
              >number doesn't exist then I forward to failed.jsp.
              > Today is Tuesday, and last Friday I was working on this and everything
              >worked fine, in fact perfect. I came in this morning to do some more
              >testing, specifically catching errors in my try and catch, example - to make
              >sure they enter in a number, and after I type in a number and hit the submit
              >button, it trys to go to the next page, but displays nothing, the page is
              >blank. Where has before, when everything was working fine on Friday, my
              >correct.jsp page or my failed.jsp page would be displayed.
              > From Friday to Tuesday I had not made any changes to my files. The only
              >thing different, that I can think of, would be that on Friday I would have
              >stoppped weblogic and this morning I started weblogic again. This is why I
              >think this is a weblogic issue or syntax on my part. I have tried to restart
              >my computer, restart weblogic, and I even deleted the .java files that
              >weblogic creates and places in the weblogic/myserver/classfiles/jsp_servlets
              >folder.
              >
              >Below is my source code.
              >Please help!
              >Thanks, jl.
              >
              ><% try {
              > <%@ include file = "db_conn.jsp"%>
              ><%
              > // A Statement object is what sends your SQL statement to the db
              > Statement stmt = conn.createStatement();
              >
              > // Retrieve the user id number from the previous form.
              > int EMP_NUM = Integer.parseInt(request.getParameter("EMP_NUM"));
              >
              > //SQL prepared statement
              > String selectEMP_NUM = "SELECT NAME, COMPANY_KEY FROM WTS_PROFILE WHERE
              >EMP_NUM=?";
              > PreparedStatement psEMP_NUM = conn.prepareStatement(selectEMP_NUM);
              > psEMP_NUM.setInt(1, EMP_NUM);
              >
              > ResultSet rsEMP_NUM = psEMP_NUM.executeQuery();
              >
              > String NAME = "";
              > int CompanyKey = 0;
              > while (rsEMP_NUM.next()) {
              > NAME = rsEMP_NUM.getString("NAME");
              > CompanyKey = rsEMP_NUM.getInt("COMPANY_KEY");
              > }// end of while
              >
              > psEMP_NUM.clearParameters();
              > psEMP_NUM.close();
              > conn.close();
              >
              > String sEMP_NUM = Integer.toString(EMP_NUM);
              > String sCompanyKey = Integer.toString(CompanyKey);
              > if (NAME.equals("")) {
              > request.setAttribute("EMP_NUM", sEMP_NUM);%>
              > <jsp:forward page="failed.jsp">
              ><% }// end of if
              > else {
              > request.setAttribute("NAME", NAME);
              > request.setAttribute("EMP_NUM", sEMP_NUM);
              > request.setAttribute("CompanyKey", sCompanyKey);%>
              > <jsp:forward page="creditcard.jsp">
              ><% }// end of else
              >}// end of try1
              >catch(Exception e) {
              ><% if(e.toString().equals("java.lang.NumberFormatException: ")) { %>
              > <font face="Arial" size="2" color="red"><center><strong>Please enter in a
              >EMPLOYEE ID NUMBER.<br><br></strong></font></CENTER>
              ><%}// end of if
              >%>
              > </TD></TR></TABLE></DIV>
              > <font color="red">"<%=e.toString()%>"</font>
              ><%
              >}// end of catch1
              >%>
              >
              >
              

  • How to make browser aware of new URL after JSP:forward

    When I use JSP:forward (or pageContext.forward() for that matter) to forward from a.jsp to b.jsp, the browser still seems to think he's at a.jsp. Assumably because the request for the new URL didn't originate with the browser. This causes problems when I try to use relative URL's in b.jsp (the forwarded URL) since the client kindly tries to resolve them for me using the wrong base URL.
    For example:
    I log in at <mysite>/Security/login.jsp.
    Here, I do some login magic and then forward to /Accounts/index.jsp.
    The state of the browser is now:
    a) the URL is <mysite>/Security/login.jsp
    b) the page displayed is <mysite>/Accounts/index.jsp
    Is there a better mechanism I can use to keep browser URL and displayed page synched up?
    BTW, in this simplified example I could use JavaScript history.go(-1) to let the browser do the forwarding itself. This won't work in my actual scenario because I actually forward to a page stored in the session several requests back.
    Any help would be very much appreciated!
    Andy

    Assumably because the request for the new URL didn't originate with >the browserThis is correct.
    One way for the browser to show the URL is by using a sendRedirect() after doing all the necessary processing. But you will loose all request attributes during a sendRedirect(). To overcome this, after you have done all processing and are ready to process the accounts jsp, you can put the required info in the session. The accounts jsp can get the info from the session instead of from the request, and then reset these in the session to prevent further use.

  • How to use jsp:forward

    I would like to show my code, because i'm not sure what u mean at the moment...i want to display the error message on the registration.jsp page and not on a new page...
    registration.jsp:
    <HTML>
    <HEAD>
    <TITLE>New Player</TITLE>
    <content = "registration.html">
    <LINK REL=stylesheet TYPE="text/css" HREF="style.css">
    <SCRIPT>
    function validateText(regForm)
    if(regForm.firstName.value=="")
    return false;
    if(regForm.surname.value=="")
    return false;
    if(regForm.email.value=="")
    return false;
    if(regForm.teamName.value=="")
    return false;
    if(regForm.pass1.value=="")
    return false;
    if(regForm.pass2.value=="")
    return false;
    return true;
    function validatePass(regForm)
    if(regForm.pass1.value!==regForm.pass2.value)
    return false;
    return true;
    function validatePassw(regForm)
    var pWord = regForm.pass1.value;
    if(pWord.length > 8)
    return false;
    else if(pWord.length < 4)
    return false;
    return true;
    function validateTeamn(regForm)
    var tName = regForm.teamName.value;
    if(tName.length > 15)
    return false;
    return true;
    function validateEmail(email)
    var result = false
    var theStr = new String(email)
    var index = theStr.indexOf("@");
    if (index > 0)
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
    result = true;
    return result;
    function doSubmit(regForm)
    if(validateText(regForm)==false)
    alert("Please complete all text fields");
    return false;
    else if (!validateEmail(regForm.email.value))
    alert("Please enter email address in the form: [email protected]");
    return false;
    else if(validateTeamn(regForm)==false)
    alert("Team Name too long");
    return false;
    else if(validatePass(regForm)==false)
    alert("Passwords did not match, please retype password");
    return false;
    else if(validatePassw(regForm)==false)
    alert("Incorrect password length, please retype password");
    return false;
    //alert("Your details are being submitted");
    //return;
    </SCRIPT>
    </HEAD>
    <BODY>
    <FONT size=4>
    Please enter the following information in the space provided below:
    </FONT>
    <CENTER>
    <FORM NAME="regForm" ACTION="confirm.jsp" METHOD=POST onSubmit="return doSubmit(regForm);">
    <B><U>Personal Details:</U></B><BR>
    <FONT SIZE=2 color="blue">(Your Team Name should be no more than 15 characters long<BR>
    & Your Password should be between 4-8 characters)</FONT><BR>
    <TABLE>
    <TR>
    <TD ALIGN="right">
    First Name:
    </TD>
    <TD ALIGN="left">
    <INPUT TYPE="text" SIZE=20 NAME="firstName">
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    Surname:
    </TD>
    <TD ALIGN="left">
    <INPUT TYPE="text" SIZE=20 NAME="surname">
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    Email Address:
    </TD>
    <TD ALIGN="left">
    <INPUT TYPE="text" SIZE=20 NAME="email">
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    Team Name:
    </TD>
    <TD ALIGN="left">
    <INPUT TYPE="text" SIZE=20 MAXLENGTH=30 NAME="teamName">
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    Password:
    </TD>
    <TD ALIGN="left">
    <INPUT TYPE="password" SIZE=8 MAXLENGTH=20 NAME="pass1">
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    Re-enter Password:
    </TD>
    <TD ALIGN="left">
    <INPUT TYPE="password" SIZE=8 MAXLENGTH=15 NAME="pass2">
    </TD>
    </TR>
    </TABLE>
    <INPUT TYPE="submit" VALUE="Register">
    <INPUT TYPE="reset" VALUE="Clear Form">
    </FORM>
    </CENTER>
    </BODY>
    </HTML>
    confirm.jsp:
    <html>
    <head>
    <basefont face="Arial">
    </head>
    <body>
    <center>
    <%@ page language="java" import="java.sql.*" %>
    <%
    // load driver
    Class.forName("org.postgresql.Driver");
    // create connection url
    String URL = "jdbc:postgresql://dbhost/ug59sxn";
    // pass database parameters to JDBC driver
    Connection Conn = DriverManager.getConnection(URL, "ug59sxn", "hupeswop");
    boolean verify = false;
    String email;
    String email2;
    email = request.getParameter("email");
    // query statement
    Statement SQLStatement = Conn.createStatement();
    // generate query
    String Query = "SELECT email FROM usertable " +
    "WHERE email = '"+email+"'";
    // get result
    ResultSet SQLResult = SQLStatement.executeQuery(Query);
    // check for email
    while(SQLResult.next())
    email2 = SQLResult.getString(1);
    if(email.equalsIgnoreCase(email2))
    verify=true;
    out.println("email already exists, please type another one");
    if(verify==false)
    %>
    <jsp:forward page="reg2.jsp"></jsp:forward>
    <%
    // close connections
    SQLResult.close();
    SQLStatement.close();
    Conn.close();
    %>
    </center>
    </body>
    </html>
    So what u r saying..i should put into my confirm.jsp -
    %>
    <jsp:forward page="registration.jsp">
    <jsp:param name="errorMessage" value="Email already exist" />
    </jsp:forward>
    <%
    but the part where i'm abit confused, what am i supposed to put in the registration.jsp page?
    thanx for the help in advance.

    Hi,
    In confirm.jsp You can put the error message in a header with response.setAttribute(sMsg, "Please type proper values"); or you can put it in session or cookie.
    And get this information in the regestration.jsp and display it.

  • About jsp:forward

    Hello everybody, sorry for my bad english.
    Finally, I let my old post to ask my question differently:
    Is it possible, with ADF, to start the application like this:
    in web.xml:
    <welcome-file>index.jsp</<elcome-file>
    in index.jsp:
    <jsp:forward page="/home.jsf"/>
    Because personally, the only method I found is:
    in web.xml:
    <welcome-file>index.jspx</welcome-file>
    with the appropriated configuration in web.xml (particularly a filter implemented manually).
    If the answer to my question is yes, please, is it possible to see you web.xml file?
    Thanks in advance.

    Thanks for your answer.
    In fact, nothing is bad with:
    <welcome-file>/home.jsf</welcome-file>
    But know if it is possible to use <jsp:forward page="/home.jsf"> could maybe help me to understand some things about the use of filters.
    Personally, as I said before, I can effectively use <welcome-file>/home.jsf</welcome-file> but this implies to implement a filter.
    In others libraries (even with Trinidad), this filter is never needed.
    So, I try to understand the difference between those two methods.
    And any information about this interest me.
    Thanks in advance.

Maybe you are looking for

  • HT204053 How do I stop the pop up for sign into iCloud?

    I Get a pop up every 10 seconds. how can I cancel it?

  • Broadcast levels workflow

    Hi there, I teach Journalism production to undergrauate journalism students. We teach the Adobe apps: Audition, Premiere, InDesign, Photoshop. In Audition, radio students construct stories with various recorded or sourced audio files in the Multitrac

  • Data Source of SOP

    Hi Gurus, I have question related to SOP and LTP on source data. I believe CO data and Capacity data can be the inputs for sales and operations planning. Could somone please guide me how to bring CO and capacity data to my planning table ( MC95) in a

  • History in Service Call

    Hi To All There is a History Tab in Service Call...In which table the values from History Tab got stored....

  • Can not setup new account in Azure

    I am trying to setup a Azure new subscription. Log on through the website and try to enter my information but the site is asking for an US state and I live in Australia??  The only zip code is the US I know is 90210 but I would prefer to setup the ac