JSP redirect

Hello All,
Im trying to figure out how to redirect a JSP paget to another page after displaying some HTML. The redirect should be time delayed though.
response.flushBuffer();
Thread.sleep(5000);
response.sendRedirect("Login.jsp?uname=" + userID);
I tried something like the above - but it did not like the call to flushbuffer. I do have some HTML I want printed before the timedelay kicks in and the page redirects. All this should be server side if possible.
Thanks,
Girish

Ugh!! No, that's not it at all. One thing at a time here....
First, your idea of response.flushBuffer()/sleep will not work because once the response buffer flushes, the first thing that happens is that the response headers are sent to the browser. Once that happens, you can't change the headers. sendRedirect uses a Location header to tell the browser to go elsewhere. So that's the problem with what you wrote, it shouldn't work.
Second, the <script ... run at server> thing, I don't know what server you are using, but that only works if the server supports server-side Javascript, and that's not many. I am also making an educated guess (I've never done server-side JS) that it wouldn't work anyway for this redirection for the same reasons as mentioned above.
So, how to do it? Well, the problem is you can't really do it from the server side. There are 2 client-side alternatives.
Javascript:
<head>
<script language="JavaScript">
// I use a separate function cuz defining the location in the onload function
// itself creates some quote issues...
function doRedirect() {
   document.location = 'Login.jsp?uname=<%= userId %>';
</script>
</head>
<body ... onload="setTimeout('doRedirect();', 5000);">
...Or META tags:
<head>
<meta http-equiv="Refresh" content="5000; URL=Login.jsp?uname=<%= userId %>">
...However, you could put the Javascript script tags in the lower body of the response and then do the same sleep thing before writing it, but it's better not to sleep the thread that is serving the page.

Similar Messages

  • JSP Redirecting

    Hey ppl. Im here asking weather JSP can redirect to a different page if some certain conditions are met. My code is:
    process.jsp
    <%
    String fname = request.getParameter("fname");
    String lname = request.getParameter("lname");
    if(((fname).equals("")) || ((lname).equals("")))
    %>
    <jsp:forward page="display.php" />
    <% } else { %>
    All variables have values
    <% } %>
    <html>
    This scriptlet checks variables for empty values. If one or all variables are empty, you get redirected to a different page. Now this is the problem, ive noticed that jsp:forward doesnt actually redirect you, it include the src code of the redirect page to the process.jsp page. If im redirecting to a PHP page with PHP code, the php page wont parse becuase the process.jsp page is ending with .jsp. Get what I mean? How can I PROPERLY redirect to a page? without using <meta refresh>? Is there a different jsp action which redirects you to a different page completly? rather than jsp:forward? thx.

    try this
    response.sendRedirect("/newJSP");
    return;

  • JSP redirection

    I have setup a jsp file for user verification, making sure that the user has properly logged in to view a page. This JSP is included on each secure area page. If the user is not verified, I want to redirect them to another page, but I'm getting a servlet exception while doing it. Here's the code I'm using:
    <jsp:useBean id="isValid" class="userValid" scope="session" />
    <%
    boolean userStatus= false;
    userStatus = isValid.getIsvalid();
    if(userStatus==false){
    response.sendRedirect("./index.html");
    else{
    response.sendRedirect("./empIndex.jsp");
    %>
    As said before, this page is simply included in other pages, which I assume is what's causing the problem.

    Location: /empPartOrderView.jsp
    Internal Servlet Error:
    javax.servlet.ServletException: Included servlet threw exception
         at org.apache.tomcat.facade.RequestDispatcherImpl.wrapException(RequestDispatcherImpl.java:552)
         at org.apache.tomcat.facade.RequestDispatcherImpl.doInclude(RequestDispatcherImpl.java:437)
         at org.apache.tomcat.facade.RequestDispatcherImpl.include(RequestDispatcherImpl.java:189)
         at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:413)
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:450)
         at empPartOrderView_5._jspService(empPartOrderView_5.java:189)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java)
         at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
         at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
         at org.apache.tomcat.core.Handler.service(Handler.java:235)
         at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
         at org.apache.tomcat.modules.server.Ajp13Interceptor.processConnection(Ajp13Interceptor.java:341)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
         at java.lang.Thread.run(Thread.java:479)
    Root cause:
    java.lang.ClassNotFoundException: TOMCAT/JSP/error.jsp
         at org.apache.tomcat.util.depend.DependClassLoader.loadClassInternal1(DependClassLoader.java:186)
         at org.apache.tomcat.util.depend.DependClassLoader12$1.run(DependClassLoader12.java:92)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.tomcat.util.depend.DependClassLoader12.loadClass(DependClassLoader12.java:90)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
         at org.apache.tomcat.facade.ServletHandler.getServlet(ServletHandler.java:343)
         at org.apache.tomcat.facade.ServletHandler.preInit(ServletHandler.java:439)
         at org.apache.tomcat.facade.ServletHandler.init(ServletHandler.java:228)
         at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:472)
         at org.apache.tomcat.facade.RequestDispatcherImpl.doInclude(RequestDispatcherImpl.java:402)
         at org.apache.tomcat.facade.RequestDispatcherImpl.include(RequestDispatcherImpl.java:189)
         at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:413)
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:450)
         at empViewAppt_9._jspService(empViewAppt_9.java:222)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java)
         at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
         at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
         at org.apache.tomcat.core.Handler.service(Handler.java:235)
         at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
         at org.apache.tomcat.modules.server.Ajp13Interceptor.processConnection(Ajp13Interceptor.java:341)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
         at java.lang.Thread.run(Thread.java:479)

  • JSP  redirect  servlets

    I'm new to jsp and servlets.I'm using jwsdp .
    my index.jsp will call a servlet and servlet will redirect to
    jsp.both jsp files are in the root
    (\jwsdp-1_0\webapps\ROOT)
    1) where should i save the servlet ??
    2) How do i call index.jsp action to servlert??
    is this correct?
    action="servlet\MyServlet";
    3) How do i come to my second jsp
    response.sendRedirect("/Mysecond.jsp");

    I don't use jwsdp so I can't help with the first question.
    If MyServlet is your servlet class name then 2 is correct. Normally you would declare your servlet and make a URL mapping in your web.xml file.
    eg:
    <web-app>
    <servlet>
    <servlet-name>ProcessOrdersServlet</servlet-name>
    <servlet-class>com.company.ProcessOrdersServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ProcessOrdersServlet</servlet-name>
    <url-pattern>/ProcessOrders</url-pattern>
    </servlet-mapping>
    </web-app>
    then in your jsp <form action="ProcessOrders">
    For question 3.
    If you have finished processing in your servlet and want to send the next display page to the browser use:
    request.getRequestDispatcher( "nextpage.jsp" ).forward( request, response );
    This will also preserve any parameters and attributes in the request object.

  • JSP Redirection fails, from Servlet

    Hi I have simple web application, where im doing some java operation in servlet and Req dispatching to JSP page
    Most of the the times, on first request i see JSP null pointer exception and in the next request service runs fine.
    Below is the error msg
    <Apr 23, 2014 2:35:12 PM EDT> <Warning> <HTTP Session> <BEA-100094> <The session id: y107TYHGnQTzJjJqndgvXDjky7bv1Q9LpHBNbBDyT4tJfyLl1RMF has been accessed from 7205002717985624119S:3.239.16.221:3.239.16.221:15001,3.239.16.221:15002:dev:soa_server1, a server that is not the primary (2944952919000475971S:3.239.16.221:[15002,15002,-1,-1,-1,-1,-1]:3.239.16.221:15001,3.239.16.221:15002:dev:soa_server2). The request URL was: NONE>
    <Apr 23, 2014 2:35:12 PM EDT> <Warning> <HTTP Session> <BEA-100094> <The session id: y107TYHGnQTzJjJqndgvXDjky7bv1Q9LpHBNbBDyT4tJfyLl1RMF has been accessed from 7205002717985624119S:3.239.16.221:3.239.16.221:15001,3.239.16.221:15002:dev:soa_server1, a server that is not the primary (2944952919000475971S:3.239.16.221:[15002,15002,-1,-1,-1,-1,-1]:3.239.16.221:15001,3.239.16.221:15002:dev:soa_server2). The request URL was: NONE>
    <Apr 23, 2014 2:35:12 PM EDT> <Warning> <HTTP Session> <BEA-100094> <The session id: y107TYHGnQTzJjJqndgvXDjky7bv1Q9LpHBNbBDyT4tJfyLl1RMF has been accessed from 7205002717985624119S:3.239.16.221:3.239.16.221:15001,3.239.16.221:15002:dev:soa_server1, a server that is not the primary (2944952919000475971S:3.239.16.221:[15002,15002,-1,-1,-1,-1,-1]:3.239.16.221:15001,3.239.16.221:15002:dev:soa_server2). The request URL was: NONE>
    <Apr 23, 2014 2:35:12 PM EDT> <Warning> <HTTP Session> <BEA-100094> <The session id: y107TYHGnQTzJjJqndgvXDjky7bv1Q9LpHBNbBDyT4tJfyLl1RMF has been accessed from 7205002717985624119S:3.239.16.221:3.239.16.221:15001,3.239.16.221:15002:dev:soa_server1, a server that is not the primary (2944952919000475971S:3.239.16.221:[15002,15002,-1,-1,-1,-1,-1]:3.239.16.221:15001,3.239.16.221:15002:dev:soa_server2). The request URL was: NONE>
    <Apr 23, 2014 2:35:12 PM EDT> <Warning> <HTTP Session> <BEA-100094> <The session id: y107TYHGnQTzJjJqndgvXDjky7bv1Q9LpHBNbBDyT4tJfyLl1RMF has been accessed from 7205002717985624119S:3.239.16.221:3.239.16.221:15001,3.239.16.221:15002:dev:soa_server1, a server that is not the primary (2944952919000475971S:3.239.16.221:[15002,15002,-1,-1,-1,-1,-1]:3.239.16.221:15001,3.239.16.221:15002:dev:soa_server2). The request URL was: NONE>
    map size is :1
    java.lang.NullPointerException
            at jsp_servlet.__downloaddocument._jspService(__downloaddocument.java:140)
            at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
            at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
            at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
            at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
            at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
            at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:526)
            at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253)
            at com.ge.render.servlets.GenerateReportServlet.doPost(GenerateReportServlet.java:81)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
            at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
            at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
            at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
            at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
            at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
            at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
            at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
            at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
            at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
            at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
            at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
            at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
            at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
            at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
            at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
            at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
            at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
            at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
            at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
            at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
            at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
            at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Please let me know, if you need source code of the files.
    Please help.
    _____________________________My JSP Page:_________________________________________
    <%@ page contentType="text/html; charset=US-ASCII" pageEncoding="US-ASCII"%>
    <%@ page import="java.util.Iterator"%>
    <%@ page import="java.util.HashMap"%>
    <%@ page import="java.util.Properties"%>
    <%@ page import="java.net.HttpURLConnection"%>
    <%@ page import="java.net.URL"%>
    <html>
        <head>
            <script type="text/javascript">
              function preloader() {
                  document.getElementById("loading").style.display = "none";
                  document.getElementById("content").style.display = "block";
              //preloader
            window.onload = setTimeout(preloader, 60000);
            </script>
            <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></meta>
            <meta http-equiv="Connection" content="keep-alive"></meta>
            <link type="text/css" rel="stylesheet" href="CSS/GridTable.css"/>
        </head>
        <body>
            <table width="100%" height="100%" class="gridtable">
                <tr height="80">
                    <th colspan="2">
                        <jsp:include page="/common/header.jsp"/>
                    </th>
                </tr>
                <tr>
                    <td>
                        <div id="loading" align="center" style="display:block">
                            <img src="images/loader.gif" alt="Loading..."></img><br></br>
                            <p>
                                Please wait. Report generation is in progress. <br>
                                 Report generation time depends on number of reports being submitted.
                            </p>
                        </div>
                        <div id="content" align="center" style="display:none">
                            Report Generation Results.<br></br><br></br>
                              <table>
                            <%
                       Properties props = new Properties();
      props=(Properties)session.getAttribute("props");
                           Properties eProps = new Properties();
      eProps=(Properties)session.getAttribute("exeProps");
                            String name = null;
                    HashMap<String, String> map= (HashMap<String, String>)request.getAttribute("url");
    //                 HashMap<String, String> Names= (HashMap<String, String>)request.getAttribute("names");
                     String key=null ;
                 System.out.println("map size is :"+map.size());
                 String Customer=null;
              if(!(map.isEmpty())){
              Iterator keySetIterator =map.keySet().iterator();
               while(keySetIterator.hasNext()){
                  key = keySetIterator.next().toString();
                   Customer=props.getProperty(key);
               if(Customer == null){
               Customer=eProps.getProperty(key);
               if(map.get(key).toString().equals("ErrorMessage.jsp")){
                                   %>
                    <tr>        <td><b>
                                <%=Customer%></b>
                             Report Generation Failed
                            <a href="<%=map.get(key)%>">click here</a>
                             to see error. </td></tr>
                            <%
               }else{
               %>
                                <tr>
                                    <td width="55%">
                                        <b>
                                            <%=Customer%></b>
                                    </td>
                                    <td width="25%">Ready</td>
                                    <td width="50%">
                                        <a href="<%=map.get(key)%>" target="_blank">click here</a>
                                    </td>
                                </tr>
                            </table>
                            <%}
          }}%>
                        </div>
                        <br></br>
                        <div id="backbutton" align="center">
                            <a href="LoginSuccess.jsp">Back</a>
                        </div>
                    </td>
                </tr>
                <tr height="40">
                    <td colspan="2">
                        <jsp:include page="/common/footer.jsp"/>
                    </td>
                </tr>
            </table>
        </body>
    </html>
    ________________________Servlet code_______________________________________________
    public class GenerateReportServlet extends HttpServlet {
      private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
        Properties FusionProps=null;
        @Override
        public void init(ServletConfig config) throws ServletException {
           super.init(config);
           try{
               FusionProps=new Properties();
            FusionProps.load(getServletContext().getResourceAsStream("/WEB-INF/Properties/Fusion.properties"));
           }catch(Exception e){
               e.printStackTrace();
      public void doPost(HttpServletRequest request,
                         HttpServletResponse response) throws ServletException,
                                                              IOException {
          String[] list1= request.getParameterValues("custs");
         if(list1 == null){
          request.setAttribute("msg", "<b><font color=\"red\">Select atleast one ReportID for custome report generation</font><b>");
          RequestDispatcher rd =
            request.getRequestDispatcher("/LoginSuccess.jsp");
          rd.forward(request, response);
        else{
             try{
             GenerateReportDAO gr=new GenerateReportDAO();
            HashMap<String, String> cust_urls = new HashMap<String, String>();
            HashMap<String, String> url_stats = new HashMap<String, String>();
             int count=list1.length;
            long starttime=System.nanoTime();
                String proxy=FusionProps.getProperty("ProxyHost");
                String port=FusionProps.getProperty("ProxyPort");
                String RUrl=FusionProps.getProperty("Url");
                String RToken=FusionProps.getProperty("xyz");
                String Furl=FusionProps.getProperty("SOACReqReceiver");
            for(int i = 0; i < count; i++)
                String URL = gr.generateReport(list1[i],proxy,port,RUrl,RToken,Furl);
                 cust_urls.put(list1[i], URL);
                if(URL=="ErrorMessage.jsp"){
                        cust_urls.put(list1[i], URL);
            long completeTime=System.nanoTime();  
             System.out.println("Total Elapsed time "+ (completeTime-starttime) + "NanoSeconds");
            request.setAttribute("url", cust_urls);
           // request.setAttribute("stats", url_stats);
         //   request.setAttribute("names", cust_names);
        RequestDispatcher rd =
          request.getRequestDispatcher("/DownloadDocument.jsp");
        rd.forward(request, response);
             catch(Exception e){
                 e.printStackTrace();
                 request.setAttribute("msg", "Server encountered internal error, Please try again. If error persists contact corporate oracle soa team.");
                 RequestDispatcher rd =
                   request.getRequestDispatcher("/ErrorMessage.jsp");
                 rd.forward(request, response);

    i have found the class and decompiled it. Pasting the contents below.
    I have tried to find something from it. didnt help.
    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3)
    // Source File Name:   __downloaddocument.java
    package jsp_servlet;
    import java.io.*;
    import java.util.*;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import weblogic.jsp.internal.jsp.JspFunctionMapper;
    import weblogic.servlet.jsp.*;
    import weblogic.utils.http.HttpParsing;
    public final class __downloaddocument extends JspBase
        implements StaleIndicator
        public __downloaddocument()
        private static void _releaseTags(PageContext pageContext, JspTag t)
            while(t != null)
                DependencyInjectionHelper.preDestroy(pageContext, t);
                if(t instanceof Tag)
                    Tag tmp = (Tag)t;
                    t = ((Tag)t).getParent();
                    try
                        tmp.release();
                    catch(Exception exception) { }
                } else
                    t = ((SimpleTag)t).getParent();
        public boolean _isStale()
            boolean _stale = _staticIsStale((StaleChecker)getServletConfig().getServletContext());
            return _stale;
        public static boolean _staticIsStale(StaleChecker sci)
            return sci.isResourceStale("/DownloadDocument.jsp", 0x1459066fe00L, "10.3.6.0", "US/Eastern");
        private static byte[] _getBytes(String block)
            try
                return block.getBytes(_WL_ORIGINAL_ENCODING);
            catch(UnsupportedEncodingException u)
                _WL_ENCODED_BYTES_OK = false;
            return null;
        public void _jspService(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
            ServletConfig config = getServletConfig();
            javax.servlet.ServletContext application = config.getServletContext();
            JspTag _activeTag = null;
            Object page = this;
            PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(this, request, response, null, true, 8192, true);
            response.setHeader("Content-Type", "text/html; charset=US-ASCII");
            JspWriter out = pageContext.getOut();
            ByteWriter _bw = (ByteWriter)out;
            _bw.setInitCharacterEncoding(_WL_ORIGINAL_ENCODING, _WL_ENCODED_BYTES_OK);
            JspWriter _originalOut = out;
            HttpSession session = request.getSession(true);
            try
                response.setContentType("text/html; charset=US-ASCII");
                _bw.write(_wl_block0Bytes, "\r\n");
                _bw.write(_wl_block0Bytes, "\r\n");
                _bw.write(_wl_block0Bytes, "\r\n");
                _bw.write(_wl_block1Bytes, "\r\n\r\n");
                _bw.write(_wl_block0Bytes, "\r\n");
                _bw.write(_wl_block2Bytes, "\r\n<html>\r\n    <head>\r\n        <script type=\"text/javascript\">\r\n          function preloader() {\r\n              document.getElementById(\"loading\").style.display = \"none\";\r\n              document.getElementById(\"content\").style.display = \"block\";\r\n          }\r\n          //preloader\r\n         // window.onload = setTimeout(preloader, 10000);\r\n        </script>\r\n        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"></meta>\r\n        <meta http-equiv=\"Connection\" content=\"keep-alive\"></meta>\r\n        <link type=\"text/css\" rel=\"stylesheet\" href=\"CSS/GridTable.css\"/>\r\n    </head>\r\n    <body>\r\n        <table width=\"100%\" height=\"100%\" class=\"gridtable\">\r\n            <tr height=\"80\">\r\n                <th colspan=\"2\">\r\n                    ");
                String __page = "/common/header.jsp";
                String __queryParams[][] = new String[0][];
                String __encoding = request.getCharacterEncoding();
                if(__encoding == null)
                    __encoding = "ISO-8859-1";
                if(__queryParams.length == 0)
                    pageContext.include(__page);
                else
                    pageContext.include(HttpParsing.makeURI(__page, __queryParams, __encoding));
                _bw.write(_wl_block3Bytes, "\r\n                </th>\r\n            </tr>\r\n             \r\n            <tr>\r\n                <td>\r\n                   <div id=\"loading\" align=\"center\" style=\"display:block\">\r\n                        <img src=\"images/loader.gif\" alt=\"Loading...\" ></img><br>\r\n                        <p> Please wait. Report generation is in progress. <br>\r\n                           Report generation time depends on number of reports submitted.</p>\r\n                    </div>\r\n                    <div id=\"content\" align=\"center\" style=\"display:none\" >\r\n                        Report Generation Results.<br><br>\r\n                       \r\n                         \r\n                        ");
                Properties props = new Properties();
                props = (Properties)session.getAttribute("props");
                Properties eProps = new Properties();
                eProps = (Properties)session.getAttribute("exeProps");
                String name = null;
                HashMap map = (HashMap)request.getAttribute("url");
                String key = null;
                System.out.println((new StringBuilder("map size is :")).append(map.size()).toString());
                if(map.size() < 5)
                    _bw.write(_wl_block4Bytes, "\r\n             <script type=\"text/javascript\">\r\n              window.onload = setTimeout(preloader, 60000);\r\n              </script>\r\n             ");
                else
                if(map.size() > 5 && map.size() < 10)
                    _bw.write(_wl_block5Bytes, "\r\n             <script type=\"text/javascript\">\r\n              window.onload = setTimeout(preloader, 80000);\r\n              </script>\r\n             ");
                else
                if(map.size() > 10)
                    _bw.write(_wl_block6Bytes, "\r\n             <script type=\"text/javascript\">\r\n              window.onload = setTimeout(preloader, 100000);\r\n              </script> \r\n             ");
                String Customer = null;
                if(!map.isEmpty())
                    for(Iterator keySetIterator = map.keySet().iterator(); keySetIterator.hasNext();)
                        key = keySetIterator.next().toString();
                        Customer = props.getProperty(key);
                        if(Customer == null)
                            Customer = eProps.getProperty(key);
                        if(((String)map.get(key)).toString().equals("ErrorMessage.jsp"))
                            _bw.write(_wl_block7Bytes, "\r\n                         \r\n                      <b>\r\n                            ");
                            out.print(String.valueOf(Customer));
                            _bw.write(_wl_block8Bytes, "</b>\r\n                         Report Generation Failed\r\n                        <a href=\"");
                            out.print(String.valueOf(map.get(key)));
                            _bw.write(_wl_block9Bytes, "\">click here</a>\r\n                         to see error.\r\n                         \r\n                        ");
                        } else
                            _bw.write(_wl_block10Bytes, "\r\n          <table>\r\n          <tr> <td width=\"55%\">\r\n           <b> ");
                            out.print(String.valueOf(Customer));
                            _bw.write(_wl_block11Bytes, "</b> </td><td width=\"25%\">Ready</td>\r\n          <td width=\"50%\"><a href=\"");
                            out.print(String.valueOf(map.get(key)));
                            _bw.write(_wl_block12Bytes, "\" target=\"_blank\">click here</a></td></tr></table>\r\n            ");
                _bw.write(_wl_block13Bytes, "\r\n                    </div>\r\n                    <br></br>\r\n                    <div id=\"backbutton\" align=\"center\">\r\n                        <a href=\"LoginSuccess.jsp\">Back</a>\r\n                    </div>\r\n                </td>\r\n            </tr>\r\n             \r\n            <tr height=\"40\">\r\n                <td colspan=\"2\">\r\n                    ");
                String __page = "/common/footer.jsp";
                String __queryParams[][] = new String[0][];
                String __encoding = request.getCharacterEncoding();
                if(__encoding == null)
                    __encoding = "ISO-8859-1";
                if(__queryParams.length == 0)
                    pageContext.include(__page);
                else
                    pageContext.include(HttpParsing.makeURI(__page, __queryParams, __encoding));
                _bw.write(_wl_block14Bytes, "\r\n                </td>\r\n            </tr>\r\n        </table>\r\n    </body>\r\n</html>");
            catch(Throwable __ee)
                if(!(__ee instanceof SkipPageException))
                    for(; out != null && out != _originalOut; out = pageContext.popBody());
                    _releaseTags(pageContext, _activeTag);
                    pageContext.handlePageException(__ee);
        private static boolean _WL_ENCODED_BYTES_OK = true;
        private static final String _WL_ORIGINAL_ENCODING = "US-ASCII".intern();
        private static final String _wl_block0 = "\r\n";
        private static final byte _wl_block0Bytes[] = _getBytes("\r\n");
        private static final String _wl_block1 = "\r\n\r\n";
        private static final byte _wl_block1Bytes[] = _getBytes("\r\n\r\n");
        private static final String _wl_block2 = "\r\n<html>\r\n    <head>\r\n        <script type=\"text/javascript\">\r\n          function preloader() {\r\n              document.getElementById(\"loading\").style.display = \"none\";\r\n              document.getElementById(\"content\").style.display = \"block\";\r\n          }\r\n          //preloader\r\n         // window.onload = setTimeout(preloader, 10000);\r\n        </script>\r\n        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"></meta>\r\n        <meta http-equiv=\"Connection\" content=\"keep-alive\"></meta>\r\n        <link type=\"text/css\" rel=\"stylesheet\" href=\"CSS/GridTable.css\"/>\r\n    </head>\r\n    <body>\r\n        <table width=\"100%\" height=\"100%\" class=\"gridtable\">\r\n            <tr height=\"80\">\r\n                <th colspan=\"2\">\r\n                    ";
        private static final byte _wl_block2Bytes[] = _getBytes("\r\n<html>\r\n    <head>\r\n        <script type=\"text/javascript\">\r\n          function preloader() {\r\n              document.getElementById(\"loading\").style.display = \"none\";\r\n              document.getElementById(\"content\").style.display = \"block\";\r\n          }\r\n          //preloader\r\n         // window.onload = setTimeout(preloader, 10000);\r\n        </script>\r\n        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"></meta>\r\n        <meta http-equiv=\"Connection\" content=\"keep-alive\"></meta>\r\n        <link type=\"text/css\" rel=\"stylesheet\" href=\"CSS/GridTable.css\"/>\r\n    </head>\r\n    <body>\r\n        <table width=\"100%\" height=\"100%\" class=\"gridtable\">\r\n            <tr height=\"80\">\r\n                <th colspan=\"2\">\r\n                    ");
        private static final String _wl_block3 = "\r\n                </th>\r\n            </tr>\r\n             \r\n            <tr>\r\n                <td>\r\n                   <div id=\"loading\" align=\"center\" style=\"display:block\">\r\n                        <img src=\"images/loader.gif\" alt=\"Loading...\" ></img><br>\r\n                        <p> Please wait. Report generation is in progress. <br>\r\n                           Report generation time depends on number of reports submitted.</p>\r\n                    </div>\r\n                    <div id=\"content\" align=\"center\" style=\"display:none\" >\r\n                        Report Generation Results.<br><br>\r\n                       \r\n                         \r\n                        ";
        private static final byte _wl_block3Bytes[] = _getBytes("\r\n                </th>\r\n            </tr>\r\n             \r\n            <tr>\r\n                <td>\r\n                   <div id=\"loading\" align=\"center\" style=\"display:block\">\r\n                        <img src=\"images/loader.gif\" alt=\"Loading...\" ></img><br>\r\n                        <p> Please wait. Report generation is in progress. <br>\r\n                           Report generation time depends on number of reports submitted.</p>\r\n                    </div>\r\n                    <div id=\"content\" align=\"center\" style=\"display:none\" >\r\n                        Report Generation Results.<br><br>\r\n                       \r\n                         \r\n                        ");
        private static final String _wl_block4 = "\r\n             <script type=\"text/javascript\">\r\n              window.onload = setTimeout(preloader, 60000);\r\n              </script>\r\n             ";
        private static final byte _wl_block4Bytes[] = _getBytes("\r\n             <script type=\"text/javascript\">\r\n              window.onload = setTimeout(preloader, 60000);\r\n              </script>\r\n             ");
        private static final String _wl_block5 = "\r\n             <script type=\"text/javascript\">\r\n              window.onload = setTimeout(preloader, 80000);\r\n              </script>\r\n             ";
        private static final byte _wl_block5Bytes[] = _getBytes("\r\n             <script type=\"text/javascript\">\r\n              window.onload = setTimeout(preloader, 80000);\r\n              </script>\r\n             ");
        private static final String _wl_block6 = "\r\n             <script type=\"text/javascript\">\r\n              window.onload = setTimeout(preloader, 100000);\r\n              </script> \r\n             ";
        private static final byte _wl_block6Bytes[] = _getBytes("\r\n             <script type=\"text/javascript\">\r\n              window.onload = setTimeout(preloader, 100000);\r\n              </script> \r\n             ");
        private static final String _wl_block7 = "\r\n                         \r\n                      <b>\r\n                            ";
        private static final byte _wl_block7Bytes[] = _getBytes("\r\n                         \r\n                      <b>\r\n                            ");
        private static final String _wl_block8 = "</b>\r\n                         Report Generation Failed\r\n                        <a href=\"";
        private static final byte _wl_block8Bytes[] = _getBytes("</b>\r\n                         Report Generation Failed\r\n                        <a href=\"");
        private static final String _wl_block9 = "\">click here</a>\r\n                         to see error.\r\n                         \r\n                        ";
        private static final byte _wl_block9Bytes[] = _getBytes("\">click here</a>\r\n                         to see error.\r\n                         \r\n                        ");
        private static final String _wl_block10 = "\r\n          <table>\r\n          <tr> <td width=\"55%\">\r\n           <b> ";
        private static final byte _wl_block10Bytes[] = _getBytes("\r\n          <table>\r\n          <tr> <td width=\"55%\">\r\n           <b> ");
        private static final String _wl_block11 = "</b> </td><td width=\"25%\">Ready</td>\r\n          <td width=\"50%\"><a href=\"";
        private static final byte _wl_block11Bytes[] = _getBytes("</b> </td><td width=\"25%\">Ready</td>\r\n          <td width=\"50%\"><a href=\"");
        private static final String _wl_block12 = "\" target=\"_blank\">click here</a></td></tr></table>\r\n            ";
        private static final byte _wl_block12Bytes[] = _getBytes("\" target=\"_blank\">click here</a></td></tr></table>\r\n            ");
        private static final String _wl_block13 = "\r\n                    </div>\r\n                    <br></br>\r\n                    <div id=\"backbutton\" align=\"center\">\r\n                        <a href=\"LoginSuccess.jsp\">Back</a>\r\n                    </div>\r\n                </td>\r\n            </tr>\r\n             \r\n            <tr height=\"40\">\r\n                <td colspan=\"2\">\r\n                    ";
        private static final byte _wl_block13Bytes[] = _getBytes("\r\n                    </div>\r\n                    <br></br>\r\n                    <div id=\"backbutton\" align=\"center\">\r\n                        <a href=\"LoginSuccess.jsp\">Back</a>\r\n                    </div>\r\n                </td>\r\n            </tr>\r\n             \r\n            <tr height=\"40\">\r\n                <td colspan=\"2\">\r\n                    ");
        private static final String _wl_block14 = "\r\n                </td>\r\n            </tr>\r\n        </table>\r\n    </body>\r\n</html>";
        private static final byte _wl_block14Bytes[] = _getBytes("\r\n                </td>\r\n            </tr>\r\n        </table>\r\n    </body>\r\n</html>");
        private static JspFunctionMapper _jspx_fnmap = JspFunctionMapper.getInstance();

  • JSP Redirection to html

    <%@ page import="java.sql.*,java.io.*" %>
    <%
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    Connection con = null;
    Statement stmt = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:malldata");
    String sql = "SELECT CUST_ID,USER_ID, PASSWORD FROM CUSTMASTER WHERE USER_ID=? and PASSWORD=?";
    ps = con.prepareStatement(sql);
    stmt = con.createStatement();
    ps.setString(1,username);
    ps.setString(2,password);
    rs = ps.executeQuery();
    if (rs.next()) {
    out.println (rs.getObject(1).toString());
    out.println (rs.getObject(2).toString());
    out.println (rs.getObject(3).toString());
    else %>
    <jsp:forward page="login.html" />
    } catch (SQLException e) {
    throw new ServletException ("servlet could not display records . " + e);
    catch (ClassNotFoundException e) {
    throw new ServletException ("Jdbc driver not found " + e);
    the forward page works always irresptive of whether the rows are returned or not. I know it returns rows as i checked it with knows values from the database. What is wrong here?

    Try giving brackets for the else loop. like this.
    if (rs.next()) {
    out.println (rs.getObject(1).toString());
    out.println (rs.getObject(2).toString());
    out.println (rs.getObject(3).toString());
    else { %>
    <jsp:forward page="login.html" />
    <%
    } catch (SQLException e) {
    throw new ServletException ("servlet could not display records . " + e);
    catch (ClassNotFoundException e) {
    throw new ServletException ("Jdbc driver not found " + e);
    Hope this helps.

  • Restricting jsp redirection

    Hi!
    I am rediretcing user's request from a.jsp to b.jsp , also i am passing some variable data from the same url.
    e.g http://127.0.0.1:8080/Main.jsp?COLS=0
    I dont want anybody to directly access this link , and i want to rediect such request to a standard error.jsp.
    How can i do this. ????

    Passing parameters in the url, a user can bookmark your page and access the link.
    I would pass data in session variables, created in page a.
    Once session variables are used in page b, set them to null.
    If the session variables are not accessible to page b, or are null, then redierect.
    Use the search bar to the left to find code for using session variables.

  • JSP links to other pages

    Hi,
    I have a web app that does not use a framework. I do try to follow the MVC pattern though by having all requests go through one Controller Servlet.
    I have a Home page jsp, which only has links to other pages. The Home JSP does not have a <form>. Just <a href's.
    These links take the user from the home page to other pages which do work and submit forms. However, some of these pages (jsp's) need to be prepopulated with data. For example, I have a page which gives a random phrase from the Database when clicking on the submit button. But when I first get to the page by following the link from Home Page, it is empty. I want to arrive at the page and have it already gotten the first phrase for me.
    One option I thought of is to have the link from the Home Page which took me to the Random Phrase page, go through the Controller servlet initially and have the Controller servlet, after having done the work of retrieving the phrase redirect to the Random Phrase page.
    If this is the correct approach, how can I accomplish this? How do I have a <a href link in a jsp, redirect to a servlet right away without submitting a form or something?
    Thanks.

    So I put this in my home.jsp:
    <a href="/Household/randomPhrase.php">Random Phrase of The Day</a> In web.xml I have this:
    <servlet>
           <servlet-name>VHController</servlet-name>
      </servlet>
      <servlet-mapping>
           <servlet-name>VHController</servlet-name>
           <url-pattern>*.php</url-pattern>
      </servlet-mapping>According to the above, when I click on this link it should take me to the Servlet's doGet() method.
    However, when I actually click on it, I get the following exception in the browser:
    java.lang.NullPointerException
         com.myapp.servlet.VHController.doPost(VHController.java:47)
         com.myapp.servlet.VHController.doGet(VHController.java:35)All I do in the doGet() method is:
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              out.println("URL: " + request.getRequestURL());
              out.println("URL: " + request.getRequestURL());
              out.println("METHOD: " + request.getMethod());Could anyone suggest what the problem may be? Why I am not getting the expected behavior?
    Thanks.

  • How can i passing chinese word parameter within jsp

    i got the issue of passing chinese parameter from one jsp to another jsp.
    my scenario is this : <br>
    i store the unicode(\u521B\u9020\u7528\u6237)in the .properties file. in 1.jsp i call the java to get the unicode from .properties file and it shows properly in 1.jsp(shows the chinese word - &#24744;&#30340;&#21517;&#23383;&#24050;&#32147;&#34987;&#20182;&#20154;&#20351;&#29992;!). then 1.jsp redirect to 2.jsp. i use request.getParameter("message") to get the chinese word. 2.jsp shows me the funny symbols(1�?). i need someone help me. below are the code of each jsp file.
    1.jsp
    %@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
    <%@ page import="java.util.Locale"%>
    <%@ page import="org.apache.commons.codec.binary.Base64"%>
    <%
         Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
         request.setCharacterEncoding("UTF-8");
         response.setContentType("text/html;charset=UTF-8"); //this is redundant
         request.getCharacterEncoding();
         response.getCharacterEncoding();     
         try {
             if (user1 != null) {
                   message+="1"+mpmservice.getLang(user.getLang(), "errmsg_username_exist")+"<br>";
                   bError=true;
              if(bError) {
                   response.sendRedirect("create_user.jsp?s=" + request.getParameter("s") + "&msg=" + message + "&name=" + name + "&description=" + description + "&phonenumber=" + request.getParameter("phonenumber") + privStr);
              %>
              <html>
              <head>
                   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              </head>     
              <body>     
              <jsp:include page="/top.jsp" />
              <p class="headline"><%=mpmservice.getLang(user.getLang(), "create_user_title")%></p>
              <form name="operatordetails" id="operatordetails" method="post" action="create_user_do.jsp">
                   <input type=hidden name=msg value="<%=message%>">
                   <table class="infotable" id="report">
                        <tr>
                             <td class="left"><%=mpmservice.getLang(user.getLang(), "create_user_label_name")%></td>
                             <td class="middle" colspan="2"><%=name%></td>
                             <td class="right"> </td>
                        </tr>
                        <tr>
                             <td class="left"> </td>
                             <td class="halfmiddle">
                                  <input class="halfmiddle" name="Create" type="submit" id="Create" value="<%=mpmservice.getLang(user.getLang(), "create_user")%>" />
                             </td>
                             <td class="halfmiddle">
                                  <input class="halfmiddle" name="Cancel" type="button" id="Cancel" value="<%=mpmservice.getLang(user.getLang(), "cancel")%>" onClick="location='create_user.jsp?s=<%=request.getParameter("s")%>&msg=<%=message%>&name=<%=name%>&description=<%=description%>&phonenumber=<%=request.getParameter("phonenumber")%><%=privStr%>'" />
                             </td>
                             <td class="right"> </td>
                        </tr>
                   </table>
              </form>
              <jsp:include page="/bottom.jsp" />
         <% } %>
         </body>
    </html>
    [[u]b]2.jsp[/b][/u]
    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
    <%@ page import="java.util.Locale"%>
    <%@ page import="org.apache.commons.codec.binary.Base64"%>
    <%
         Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
      request.setCharacterEncoding("UTF-8");
         response.setContentType("text/html;charset=UTF-8"); //this is redundant
         request.getCharacterEncoding();
         response.getCharacterEncoding();
         try {
             String message = request.getParameter("msg");
             System.out.println("in create_user.jsp  message>>>>>"+message);
              %>
              <html>
              <head>
                   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              </head>     
              <body>               
              <jsp:include page="/top.jsp" />
              <p class="headline"><%=mpmservice.getLang(user.getLang(), "create_user_title")%></p>
              <form name="operatordetails" id="operatordetails" method="post" action="create_user_confirm.jsp">
                   <input type=hidden name=s value="<%=request.getParameter("s")%>">
                   <table class="infotable" id="report">
                        <tr>
                             <td class="left"><%=mpmservice.getLang(user.getLang(), "create_user_label_name")%></td>
                             <td class="middle" colspan="2"><input class="middle" name="name" type="text" id="name" size="35" value="<%=name%>" /></td>
                             <td class="right">
                             <% if (message!=null && message!="" && message.startsWith("1") ) { %>
                                  <%=message.substring(1,message.indexOf("<br>")) %>
                                  <% message=message.substring(message.indexOf("<br>")+4,message.length()); %>
                             <% } %>
                              </td>
                        </tr>
                   </table>
              </form>
              <jsp:include page="/bottom.jsp" />
         <% } %>
         </body>
    </html>
    [u].properties file[/u]
    errmsg_username_exist=\u60A8\u7684\u540D\u5B57\u5DF2\u7D93\u88AB\u4ED6\u4EBA\u4F7F\u7528!
    [\code]
    i really appreciate whoever reply this issue.
    thanks a lot

    i got the issue of passing chinese parameter from one jsp to another jsp.
    my scenario is this : <br>
    i store the unicode(\u521B\u9020\u7528\u6237)in the .properties file. in 1.jsp i call the java to get the unicode from .properties file and it shows properly in 1.jsp(shows the chinese word - &#24744;&#30340;&#21517;&#23383;&#24050;&#32147;&#34987;&#20182;&#20154;&#20351;&#29992;!). then 1.jsp redirect to 2.jsp. i use request.getParameter("message") to get the chinese word. 2.jsp shows me the funny symbols(1�?). i need someone help me. below are the code of each jsp file.
    1.jsp
    %@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
    <%@ page import="java.util.Locale"%>
    <%@ page import="org.apache.commons.codec.binary.Base64"%>
    <%
         Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
         request.setCharacterEncoding("UTF-8");
         response.setContentType("text/html;charset=UTF-8"); //this is redundant
         request.getCharacterEncoding();
         response.getCharacterEncoding();     
         try {
             if (user1 != null) {
                   message+="1"+mpmservice.getLang(user.getLang(), "errmsg_username_exist")+"<br>";
                   bError=true;
              if(bError) {
                   response.sendRedirect("create_user.jsp?s=" + request.getParameter("s") + "&msg=" + message + "&name=" + name + "&description=" + description + "&phonenumber=" + request.getParameter("phonenumber") + privStr);
              %>
              <html>
              <head>
                   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              </head>     
              <body>     
              <jsp:include page="/top.jsp" />
              <p class="headline"><%=mpmservice.getLang(user.getLang(), "create_user_title")%></p>
              <form name="operatordetails" id="operatordetails" method="post" action="create_user_do.jsp">
                   <input type=hidden name=msg value="<%=message%>">
                   <table class="infotable" id="report">
                        <tr>
                             <td class="left"><%=mpmservice.getLang(user.getLang(), "create_user_label_name")%></td>
                             <td class="middle" colspan="2"><%=name%></td>
                             <td class="right"> </td>
                        </tr>
                        <tr>
                             <td class="left"> </td>
                             <td class="halfmiddle">
                                  <input class="halfmiddle" name="Create" type="submit" id="Create" value="<%=mpmservice.getLang(user.getLang(), "create_user")%>" />
                             </td>
                             <td class="halfmiddle">
                                  <input class="halfmiddle" name="Cancel" type="button" id="Cancel" value="<%=mpmservice.getLang(user.getLang(), "cancel")%>" onClick="location='create_user.jsp?s=<%=request.getParameter("s")%>&msg=<%=message%>&name=<%=name%>&description=<%=description%>&phonenumber=<%=request.getParameter("phonenumber")%><%=privStr%>'" />
                             </td>
                             <td class="right"> </td>
                        </tr>
                   </table>
              </form>
              <jsp:include page="/bottom.jsp" />
         <% } %>
         </body>
    </html>
    [[u]b]2.jsp[/b][/u]
    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
    <%@ page import="java.util.Locale"%>
    <%@ page import="org.apache.commons.codec.binary.Base64"%>
    <%
         Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
      request.setCharacterEncoding("UTF-8");
         response.setContentType("text/html;charset=UTF-8"); //this is redundant
         request.getCharacterEncoding();
         response.getCharacterEncoding();
         try {
             String message = request.getParameter("msg");
             System.out.println("in create_user.jsp  message>>>>>"+message);
              %>
              <html>
              <head>
                   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              </head>     
              <body>               
              <jsp:include page="/top.jsp" />
              <p class="headline"><%=mpmservice.getLang(user.getLang(), "create_user_title")%></p>
              <form name="operatordetails" id="operatordetails" method="post" action="create_user_confirm.jsp">
                   <input type=hidden name=s value="<%=request.getParameter("s")%>">
                   <table class="infotable" id="report">
                        <tr>
                             <td class="left"><%=mpmservice.getLang(user.getLang(), "create_user_label_name")%></td>
                             <td class="middle" colspan="2"><input class="middle" name="name" type="text" id="name" size="35" value="<%=name%>" /></td>
                             <td class="right">
                             <% if (message!=null && message!="" && message.startsWith("1") ) { %>
                                  <%=message.substring(1,message.indexOf("<br>")) %>
                                  <% message=message.substring(message.indexOf("<br>")+4,message.length()); %>
                             <% } %>
                              </td>
                        </tr>
                   </table>
              </form>
              <jsp:include page="/bottom.jsp" />
         <% } %>
         </body>
    </html>
    [u].properties file[/u]
    errmsg_username_exist=\u60A8\u7684\u540D\u5B57\u5DF2\u7D93\u88AB\u4ED6\u4EBA\u4F7F\u7528!
    [\code]
    i really appreciate whoever reply this issue.
    thanks a lot

  • How to Include a servlet in a jsp

    Hello,
    My jsp pages are all tied to respective Servlets. So when I have to forward to a jsp, I forward to a servelt which redirects to that jsp.
    Now I have a jsp page which has to include another jsp page.
    So I am trying to include a servlet in my jsp page which inturn redirects itself to the included jsp.
    Have tried doing the following
    <jsp:include page="../../servlet/ServletName" flush="true">
    </jsp:include>
    does not work. It compiles well but no output
    any ideas ????
    ~ Soumya

    It does not seem to work... Let me give you the snippet of code I used.
    calendarEntry.java - the parent jsp
    <tr rowspan="60%">
    <td width="100%">
         <jsp:include page="file://c:/../../servlet/MonthEventList">
         </jsp:include>
    </td>
    </tr>
    MonthEventList.java - the included servlet
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class MonthEventList extends HttpServlet {
         * Attributes
         private static final String CONTENT_TYPE = "text/html";
         private HttpSession session;
         public void init() throws ServletException
         public void doPost(HttpServletRequest request,
    HttpServletResponse response) throws
    ServletException, IOException
              try {     
              HttpSession session = request.getSession(true);
              String url;
         url = "/jsp/site/calendar/monthEventList.jsp";
                        //ReDirect to where the page is going
                        response.sendRedirect(url);
                        return;
              } catch (Exception ex) {
              String url="/jsp/site/calendar/main/servletError.jsp;
         response.sendRedirect(url);
              return;
         public void doGet(HttpServletRequest request,HttpServletResponse
    response) throws ServletException, IOException
              doPost(request, response);
    monthEventList.jsp
    just displays some dummy data
    So if this is the case, do you think the <jsp:include> can work ??
    Thanks in advance
    Soumya

  • Extremely difficult to debug, about EJB, JSP

    These codes are in a JSP page, an EJB will be looked up:
    addcd.jsp
    <%!
       private CDAdder cdadder = null;
       public void jspInit() {
          try {
             InitialContext ic = new InitialContext();
             Object objRef = ic.lookup("CDAdderBean");
            CDAdderHome home = (CDAdderHome)PortableRemoteObject.narrow(objRef, CDAdderHome.class);
             cdadder = home.create();
          } catch (RemoteException ex) {
                System.out.println("Remote Exception:"+ ex.getMessage());
          } catch (CreateException ex) {
                System.out.println("Create Exception:"+ ex.getMessage());
          } catch (NamingException ex) {
                System.out.println("Unable to lookup home: " + ex.getMessage());
       public void jspDestroy() {   
             cdadder = null;
    %>
    <%
    HttpSession httpsession=request.getSession();
    httpsession.setAttribute("cdadder",cdadder); //i want to add this object to the session so that i could retrieve it and use its methods in other JSP pages.
    %>
    <form method="post" action="addtrack.jsp">
    <input type=text name="TitleOfTrack">
    <input type=text name="DurationOfTrack">
    <input type="submit">
    </form>
    ......................................addtrack.jsp
    <%
    CDAdder cdadder=(CDAdder)request.getSession().getAttribute("cdadder");// get back the object in the session
    String TitleOfTrack=request.getParameter("TitleOfTrack");
    String DurationOfTrack=request.getParameter("TitleOfTrack");
    cdadder.addTrack(new Track(TitleOfTrack,DurationOfTrack) ); //add the Track object into the arraylist using the addTrack(Track track) method in the CDAdderBean
    response.sendRedirect(addcd.jsp); //redirect back to the addcd.jsp page
    %>CDAdderBean.java
    public class CDAdderBean implements SessionBean {
         // data item to hold a reference to a passed Session context     private SessionContext ctx;
         private ArrayList tracks=new ArrayList();   << This arraylist holds the Track objects
         public void addTrack(Track track) throws RemoteException{
              tracks.add(track); //one method for adding tracks to the arraylist
         public void removeTrack(int index) throws RemoteException{
              tracks.remove(index); //another method for removing a track from the arraylist
         public ArrayList getListOfTracksAL() throws RemoteException{
    return tracks;
    ...............................Each time the user enters the required fields(title,duration) to add a track, these parameters will be passed to the addtrack.jsp, and the addtrack.jsp will retrieve the cdadder object from the session and use its addTrack method to add the track to the arraylist. And when it finishes, it will redirect back to the addcd.jsp. I got some other codes in the addcd.jsp(I did not show it as it will look very messy), anyway, the codes includes a call to the getListOfTracksAL() method which will return an arraylist of Track objects.
    my problem is that, EVERY TIME i started the sun application server, and go to the addcd.jsp, then the FIRST TIME I entered all the required fields and click submit button . I expected the parameters would be passed to the addtrack.jsp and it would add the track to the arraylist for me and then returned to addcd.jsp and the addcd.jsp would display the track that I just tried to add.
    but it didn't.
    I am sure that it DID add the track to the arraylist because i tried to print the size of the arraylist after the addTrack method was invoked.
    the most strange thing was that the addcd.jsp would display the tracks correctly after the FIRST TIME of adding a track.
    Please take a look at this link if you have time:
    http://222.166.192.130:8080/E-Music/login.jsp
    username:aaaaaa
    password:aaaaaa
    choose the role as "Admin"
    Add new music recording
    note: processor.jsp in this web server is the addtrack.jsp I was referring to.
    Many thanks to you all.

    ya
    i tried to add some println statements and noticed that:
    the first time i tried to add a track, the addTrack method was really invoked and the size of the arraylist became 1
    but when it returns to the addcd.jsp page the arraylist became empty
    but the most strange thing was that, it worked correctly AFTER the first time.
    thank you very much for your advice.

  • 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..

  • ForEach tag problem in JSP

    I have this next code, but the forEach tag doesn't seem to work! However, the line <c:out value='${lista[1]}'/> does work. Can you help me with the problem, please?
    <%@     page
         contentType = "text/html;charset=iso-8859-1"
         session="true"
         language="java"
         import = "java.lang.*"
         import = "java.util.*"
    %>
    <c_rt:if test='<%= request.getParameter("hinicio") != null %>'>
              <%
                   ArrayList Valores = new ArrayList(4);
                   Valores.add(request.getParameter("text1"));
                   Valores.add(request.getParameter("text2"));
                   Valores.add(request.getParameter("text3"));
                   Valores.add(request.getParameter("text4"));
                   Valores.add(request.getParameter("text5"));
                   pageContext.setAttribute("lista", Valores);
              %>
              <c:forEach var='x' items='<%= Valores %>'>
                   <c:out value='${x}'/>
              </c:forEach>
    <c:out value='${lista[1]}'/>
    </c_rt:if>
    <html>
    <head>
         <title>Tarea</title>
         <script type="text/javascript">
              function Inicio()
                   forma.hinicio.value = "ok";
                   forma.submit();
         </script>
    </head>
    <body>
    <form name="forma" method="post" action="Tarea.jsp">    //Redirects to itself
         <input type="hidden" name="hinicio">
         <center>
         <br>
         <input type="text" name="text1" value="0">
         <br>
         <input type="text" name="text2" value="0">
         <br>
         <input type="text" name="text3" value="0">
         <br>
         <input type="text" name="text4" value="0">
         <br>
         <input type="text" name="text5" value="0">
         <br>
         <br>
         <input type="text" name="rango1" value="0">   <input type="text" name="rango2" value="0">
         <br>
         <br>
         <input type="button" value="Aceptar" onClick="Inicio()">
         <br>
         <br>
         <input type="text" name="resultado" value="0">
         </center>
    </form>
    </body>
    </html>

    You seem to be using both the EL and the RT JSTL libs on the same page.
    If you are in a JSP1.2 container, then you can only use EL with the EL tags, and <%= expr %> with the rt tags.
    If you have a JSP2.0 container (eg Tomcat 5) properly configured (ie web.xml is version 2.4) then you should use JSTL1.1, which accepts both sorts of expressions. (${expr} is a runtime expression in JSP2.0)
    Try either
    <c:forEach var='x' items='${lista}'>
    or
    <c_rt:forEach var='x' items='<%= Valores %>'>

  • Question about redirecting to other pages

    I have read that redirecting in jsp pages is not working sometimes. The redirection is propably works with Cookies, so if a client would disable all the Cookies from his browser the redirection would not work at all. I use the response.sendRedirect("...") command for this. Does anybody know if this problem stands and if so is there any way or other command to avoid it?
    Thank You !!!

    Yes I agree the JSP redirect should always work. Cookies or no Cookies... on Any browser... This a a server side header replacement, so it should be very reliable.

  • JSF URL redirection

    I want the user to type in the browser
    http://my.website.com
    which would be forwarded to this.
    http://my.website.com/CTOpsProd/faces/frames.jsp
    It would be great if someone could tell me a simple way to do this using JSF or websphere setup
    thanks

    Just add JavaScript code like location = 'CTOpsProd/faces/frames.jsp'; to Your index.jsp
    or use <jsp:redirect> tag.
    I want the user to type in the browser
    ttp://my.website.com
    hich would be forwarded to this.
    http://my.website.com/CTOpsProd/faces/frames.jsp
    t would be great if someone could tell me a simple
    way to do this using JSF or websphere setup
    thanks

Maybe you are looking for

  • Dúvidas sobre B2B

    Bom dia ALL, Tenho algumas dúvidas  a levantar em relação ao B2B - XML Email. Primeiro ponto) Caso o fornecedor envie uma nota fiscal que esta em duplicidade, usando ou não a solução GRC, vou receber duas vezes na caixa de e-mail ? Se isso acontecer,

  • Battery completely drained on 15" MBP - charged but now computer has errors

    The other night I came home from work and found my mac had been completely drained. I plugged the computer in and it charged up, however when I turned it on it has been a nightmare ever since. I had to reset the date/time settings on the computer, an

  • AVI files with iDVD??

    does anyone know how to make a 45min long avi file work with iDVD? i want to burn them to a watchable DVD, thanks

  • Oracle.jbo.RowNotFoundException: JBO-25034: Row with handle not found

    Hello, I am developing a fusion web application on Jdeveloper 11.1.2.1.0. I have a ADF table which is bound to a table in the backing bean. There is a "Process" button for each row that works completely fine. There is button called "Process All" bene

  • Works with my PPC but not my Intel mac

    Anyone??.....my shuffle works fine with my old powerbook(even though its not the itunes source) but seems to bring my new Intel Imac to it's knees. Only a week ago it the imac was it's main source, now it crashes while updating songs, can't eject, ca