JSP with servlet content

hello, i am currently writing a search engine, i have written a servlet which connects to and queries a Microsoft SQL server database and then writes the results to the page seen by the user, Formatting the output text through a servlet is however very teedious, is there any way that i could call the servlet from within a jsp scriptlet or expression, and have the formatted string (HTML) returned and printed to the place that it was called (the scriptlet or expression) on the jsp. Any other methods would me more than welcome.
Also, i would like to know how to read in a text/html file from within a servlet i have tried putting the file in the same folder as the class ( "web-inf/classes" ) and just creating a FileReader object with the file name as the parameter, however i get a file not found error.
Thanks in advance
Arnold Oree

You can incluse the output from a servlet in your jsp page using the include tag. You can also pass parameters to the servlet like the example below shows (but doesn't have to use a complicated technique like I used ...it could just be a hardcoded value).
  <jsp:include page='servlet/counter' flush='true'>
    <jsp:param name='counter'
       value='<%="portaluser_"+session.getAttribute("userName")%>'/>
  </jsp:include>You could use a cheat like this to see where your container is 'rooting' from regarding reading from the local filesystem. Different setups might give different results.
      File f = new File("Hi.dat");
      System.out.println(f.getAbsolutePath());However, sometimes people use an absolute path and allow that to be configured in the web.xml file.
  <servlet>
    <servlet-name>counter</servlet-name>
    <servlet-class>com.GumBTech.servlet.Counter</servlet-class>
    <init-param>
      <param-name>countfile</param-name>
      <param-value>E:\security\counts.ser</param-value>
    </init-param>
  </servlet>Then you just read the value from the servlets init method.
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {
      // Get the save file.
      countfile = new File(config.getInitParameter("countfile"));
      // ...etc, etc...I hope this gives you some ideas.

Similar Messages

  • JSP with Servlets?

    Hi
    is it possible to access a servlet with a JSP page?
    The examples I've seen so far, only accesses Java Beans on the Server... ? What I like to do: i have a servlet on the server and now i would like to write JSP pages with HTML forms that all posts their data to this servlet. How is this done?
    Thanks in advance!

    Nope, that doesn't work! The result JSP page doesn not show the values. Here's my code:
    servlet:
    Object o = request.getParameter("value");
    Object myValue = "ServletValue";
    request.setAttribute("servletvalue", myValue);
    RequestDispatcher rd;
    rd = getServletContext().getRequestDispatcher("/response.jsp");
    rd.forward(request, response);
    response.jsp:
    Your value: <% request.getParameter("value"); %><BR>
    My value : <% request.getParameter("servletvalue"); %><BR>
    val: <% request.getAttribute("value"); %><BR>
    sval: <% request.getAttribute("servletvalue"); %><BR>
    parameters : <% request.getParameterNames(); %><BR>
    the response.jsp does no show the request.getXXX() values. the values are valid in the servlet (tested). but somehow they get lost thourgh access of the second JSP page to which the request/response is forwarded to ... ?

  • JSP and Servlets? What's the difference?

    I've got this book, and it's mixing servlet with jsp and then jsp with servlet. Can we just use one and still make a web application? What is the difference between the both? Can anyone give me a basic idea behind these 2 J2ee technologies.

    hi,
    Both use server-side Java to dynamically generate web pages. The source code to a JSP looks like HTML, with Java embedded inside
    (a) normal HTML tags, (b) JSP tags like <jsp:include>, (c) custom tags, (d) scriptlets (Java code surrounded with <% and %>).
    The source code to a servlet looks like Java, with HTML embedded in out.print(...) statements. Both use the Servlet API to communicate with the web server and the client. In fact, a JSP gets compiled into a servlet, so they're almost identical in terms of expressive power. The choice is, whether you're more comfortable coding your pages in Java or in JSP-style HTML; and since you can call a JSP from a Servlet and vice versa, you don't have to make an either-or decision.
    Karthick PalaniChamy

  • How to upload a file into server using j2ee jsp and servlet with bean?

    How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
    Anyone help me please!

    u don't need j2ee and struts to do file uploading. An example is as such
    in JSP. u use the <input> file tag like
    <input type="file"....>You need a bean to capture the file contents like
    class FileUploadObj {
        private FormFile srcFile;
        private byte[] fileContent;
        // all the getter and setter methods
    }Then in the servlet, you process the file for uploading
        * The following loads the uploaded binary data into a byte Array.
        FileUploadObj form = new FileUploadObj();
        byte[] byteArr = null;
        if (form.signFile != null) {
            int filesize = form.srcFile.getFileSize();
            byteArr = new byte[filesize];
            ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
            bytein.read(byteArr);
            bytein.close();
            form.setFileContent(byteArr);
        // Write file content using Writer class into the destination file in the server.
        ...

  • Creating FOrums with Servlet and JSP

    Hi everyone,
    Is there a good resource that explains how to build a forum using servlets and JSP technology?
    Regards,
    Basil Mahdi

    please let me know here if you find any useful resources...I am in the process of writing my own searchable threaded forum for my company with JSP's/servlets. It's a very slow process at the moment though...if I ever finish it, I'll gladly share it.

  • Which is better to connect with MIDlet? jsp or servlets

    Hello to all,
    I am Vishnu from India. I have tried connecting MIDlet with jsp but not using servlet. Few asked me to use servlet to connect to MIDlet.
    I want to connect to database (sql server) from MIDlet.
    I do not know which should I go for ,
    what should i choose whether jsp or servlet?
    If I choose servlet, can i create new servlets on the run, is it possible?
    Thank you in advance,

    hey vishnu,
    can u please tell me how to Connect a servlet/jsp using a midlet.. i also want to connect SQL Server .
    i have one application on JSP and i want tht application to run on j2me platform.
    i hope u ll help me.
    thnx
    Ahmed

  • Servlet/JSP with Tomcat

    Where is the best place on the Web to learn Servlet/JSP with Tomcat for beginners?

    i also just started learning servlets a few days ago.
    here are some of the websites i've found
    there are some tutorials as well as general tips and stuff.
    http://java.sun.com/docs/books/tutorial/servlets/index.html
    http://www.javaworld.com/javaworld/javatips/jw-javatip94.html
    http://www.cetus-links.org/oo_javaserver_pages.html
    http://www-105.ibm.com/developerworks/education.nsf/dw/java-onlinecourse-bynewest?OpenDocument&Count=500&loc=j
    http://www.fawcette.com/javapro/2002_03/online/online_eprods/servlets_03_08/
    http://developer.java.sun.com/developer/onlineTraining/Servlets/Fundamentals/index.html
    http://developer.java.sun.com/developer/onlineTraining/JSPIntro/
    http://www.novocode.com/doc/servlet-essentials/
    http://hotwired.lycos.com/webmonkey/99/07/index3a.html?tw=programming
    http://www.jguru.com/faq/Servlets
    http://www.jguru.com/faq/JSP
    i haven't looked into all of these yet, but i'm sure they will help you.

  • Delete data dynamically with JSP and servlet (Very Urgent)

    Hi,
    I am new with servlets and JSP. On my jsp page I am populating customer names in a drop box from database and I have 3 buttons ADD, DELETE and EDIT.
    Now when I press DELETE buttong I am calling delete function which is writen in Javascript on my jsp file only,now I want to pass these selcted values ehich I have stored in an array to be pass to servlet,so I can write Delete query for it and delete.
    Could anyone help with sample code>
    Here what I am trying to say:
    <HTML>
    <HEAD>
    <script language="JavaScript" type="text/javascript">
    <!--
    function remove()
    var u = confirm("Are you sure you want to Delete Selected names?")
    if (u==true)
         var selectedArray = new Array();
         var selObj = document.getElementById('CUSTOMER_NAME');
         var i;
         var count = 0;
         for (i=0; i<selObj.options.length; i++) {
         if (selObj.options.selected) {
         selectedArray[count] = selObj.options[i].value;
         count++;
         alert("names to be deleted are:"+selectedArray);
         // selectedArray has the selected items stored
         alert("Items Deleted!")
    else
    alert("No data were deleted!!You pressed Cancel!")
    //-->
    </script>
    </HEAD>
    <BODY>
    //calling servlet on action tag of form
    <FORM METHOD= 'POST' ACTION='Remove_Customer'>
    <form ><INPUT TYPE='submit' NAME='DELETE' VALUE='DELETE' onclick="remove()"></TD></form>
    <form><INPUT TYPE='submit' NAME='MODIFY' VALUE='MODIFY' onclick="modification()" ></TD></form>
    </BODY>
    </HTML>
    PLEASE HELPME,it's very urgent.
    Since the selected Array is in javascrip language , I don't know how can I pass that to servlet.
    request.getParameter is not working,since it's an array
    Many thanks in Advance.

    Hey,
    I am having problem deleting multiple values.
    If I just select one value,it deletes it
    But for multiple values the code is not working right.
    If there 2 values selcted then the last value gets deleted,if there are more than 2 values selected none values delete.
    Could plese check the code,and let meknow what mistake am I doing?
    Please help
    String delName="";
    int pos = tStr.indexOf(",");
    System.out.println(pos);
         if (pos != -1)
                   delName = tStr.substring(0, tStr.indexOf(","));
              tStr = tStr.substring(tStr.indexOf(",") + 1 );
                   System.out.println("DElName:"+delName);
                   System.out.println("tStr::"+tStr);                              
                        delName = tStr;
                        delete_Customer(delName);
    Thanks
    ASH

  • Object living with servlet/jsp container

    How do I make an Object live until the servlet container lives? I mean I want an Object to be instantiated once in the lifetime of the webserver session and its has to be singleton and should live alive until the webserver dies? How can I make this possible? I should be able to keep that object alive even if any no references are made to the object. Moreover I should be able to access that object from any java class on that webserver?

    You can't do this in memory. The easiest thing to do would be to read/write the persistant data you need from disk.
    Anything your JSP or servlet creates in memory will be cleared when it is done serving the request.

  • Urgent: problem with sharing HttpSession  object between Jsp and servlets.

    Hi,
              We are using weblogic 6.0 sp2.
              I m setting a particular object in session in a servlet using
              session.setAttribute() but when i try to retrieve that object using
              session.getAttribute() in a jsp page the value of that object is null. Is
              there any way to configure HttpSession in weblogic so that jsps and servlet
              can share the same session? Or any workaround for this problem.
              Any help in this regard is appreciated.
              Thanks
              -Shree
              

    Just a guess, but it sounds like you have cookies turned off and are not
              using encodeURL. Try enabling cookies and see if that solves the problem.
              Also, it is generally good practice to use encodeURL to protect yourself
              from users who disable session cookies.
              Here's how we use encodeURL in our Servlets:
              gotoPage("/jsp/someJSP.jsp");
              private void gotoPage( String address,
              HttpServletRequest request,
              HttpServletResponse response )
              throws ServletException, IOException
              RequestDispatcher dispatcher =
              etServletContext().getRequestDispatcher( response.encodeURL( address ));
              dispatcher.forward( request, response );
              "Shree Unde" <[email protected]> wrote in message
              news:[email protected]..
              > Hi,
              > We are using weblogic 6.0 sp2.
              > I m setting a particular object in session in a servlet using
              > session.setAttribute() but when i try to retrieve that object using
              > session.getAttribute() in a jsp page the value of that object is null. Is
              > there any way to configure HttpSession in weblogic so that jsps and
              servlet
              > can share the same session? Or any workaround for this problem.
              > Any help in this regard is appreciated.
              > Thanks
              > -Shree
              >
              >
              

  • PL/SQL vs JSP vs Servlets

    We are in the stage of deciding which language to develop portlets. I lean towards JSP or servlets for the wide array of Java libraries we can use. I think the only advantage of PL/SQL is speed. Thanks.

    It depends. If your developers are mainly Java developers, you'll probably prefer building web portlets. But if you have a strong PL/SQL skill set you could choose the latter. Additionally, if you're developing content that is database intensive you may want to build PL/SQL portlets since they transact with the database faster. If you're going to aggregate content from various web sites, using web providers is preferable. It's a matter of choice based on your requirements and preferences.

  • Deploying a WAR file containing .jsp and servlets (also uses JNI)

    Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
    We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
    Server documentation on deploying such files.
    This is how we went about it:
    1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
    Server.
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
    and
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
    (We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
    service packs)
    From browser, open http://yourserver:8888/
    Click on Select a Server:Manage
    Click on Virtual Server Class
    Click on https-yourserver
    Click on the Web Applications Tab
    Then, click on Deploy Web Application
    Enter the following -
    WAR File On: Local
    WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Application URI: /jakarta
    Installation Directory: c:\iPlanet\examples\jakarta-examples
    By clicking on OK it deployed the application.
    I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
    Edit     /jakarta     c:/iPlanet/examples/jakarta-examples
    Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
    - [images]
    - [jsp]
    - index.html
    - [servlets]
    - [META-INF]
    - [WEB-INF]
    - [classes]
    - [tlds]
    - web.xml
    - index.html
    I restarted the server and accessed it using the following URL from my IE browser:
    http://yourserver/jakarta/index.html
    Then I clicked on the JSP Examples and tried some JSP examples.
    b) Alternatively, you can also deploy the same example from the command-line.
    Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
    wdeploy deploy      -u /jakarta
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\jakarta-examples
              C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Restart the web server (I don't think you have to restart, but .. might as well).
    2)Deploy your web-application
    My Foo.war has the following structure.
    You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
    in your PATH)
    Foo.war
    - [META-INF]
    - [WEB-INF]
    - web.xml
    - [classes]
    - Bar.class
    - MoServlet.class
    - [lib]
    - ThirdParty.jar
    - [natlib]
    - extlib.dll
    - foo.jsp
    Here is our application scenario:
    foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
    ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
    Now to deploy it, do the following:
    (a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
    JSP compile error).
    <%@page language="java" import="Bar" contentType="text/html"%>
    (b) Check web.xml (for Servlets)
    Within web.xml, make sure you have the following mappings:
    <servlet>
    <servlet-name> MoLink </servlet-name>
    <servlet-class> MoServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> MoLink </servlet-name>
    <url-pattern> /servlet/Mo </url-pattern>
    </servlet-mapping>
    (c) Deploy the application
    Using command line:
    wdeploy deploy      -u /foo
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\foo-dir
              Foo.war
    (d) Change web-apps.xml file (for picking up ThirdParty.jar)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    You should see something similar to following after successful deployment.
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
    Change it to look like following to pick up the ThirdParty.jar
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
    <class-loader reload-interval="300"
              classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
              delegate="false"/>
    </web-app>
    (e) Change jvm12.conf file (for JNI)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    Add or uncomment the following lines:
    #optional - just helps with instrumenting the jsp and servlet code
    jvm.include.CLASSPATH=1
    jvm.enableDebug=1
    nes.jsp.enabledebug=1
    jvm.trace=7
    jvm.verboseMode=1
    #required for JNI
    java.compiler=NONE
    jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
    jvm.option=-Xrs
    jvm.option=-Xnoagent
    # not sure if this is needed for iPlanet web server
    jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
    (f) Change magnus.conf file (for JNI)
    We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
    iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
    in Path, it didn't work.
    Change Extrapath directive:
    ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    to
    ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    (g) Apply changes from the Web Server Administration Console and Restart the web server.
    You should be able to see the behaviour that you want from your application.
    http://yourserver/foo/foo.jsp
    Hope this was helpful!!!
    Sonu

    Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
    We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
    Server documentation on deploying such files.
    This is how we went about it:
    1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
    Server.
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
    and
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
    (We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
    service packs)
    From browser, open http://yourserver:8888/
    Click on Select a Server:Manage
    Click on Virtual Server Class
    Click on https-yourserver
    Click on the Web Applications Tab
    Then, click on Deploy Web Application
    Enter the following -
    WAR File On: Local
    WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Application URI: /jakarta
    Installation Directory: c:\iPlanet\examples\jakarta-examples
    By clicking on OK it deployed the application.
    I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
    Edit     /jakarta     c:/iPlanet/examples/jakarta-examples
    Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
    - [images]
    - [jsp]
    - index.html
    - [servlets]
    - [META-INF]
    - [WEB-INF]
    - [classes]
    - [tlds]
    - web.xml
    - index.html
    I restarted the server and accessed it using the following URL from my IE browser:
    http://yourserver/jakarta/index.html
    Then I clicked on the JSP Examples and tried some JSP examples.
    b) Alternatively, you can also deploy the same example from the command-line.
    Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
    wdeploy deploy      -u /jakarta
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\jakarta-examples
              C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Restart the web server (I don't think you have to restart, but .. might as well).
    2)Deploy your web-application
    My Foo.war has the following structure.
    You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
    in your PATH)
    Foo.war
    - [META-INF]
    - [WEB-INF]
    - web.xml
    - [classes]
    - Bar.class
    - MoServlet.class
    - [lib]
    - ThirdParty.jar
    - [natlib]
    - extlib.dll
    - foo.jsp
    Here is our application scenario:
    foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
    ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
    Now to deploy it, do the following:
    (a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
    JSP compile error).
    <%@page language="java" import="Bar" contentType="text/html"%>
    (b) Check web.xml (for Servlets)
    Within web.xml, make sure you have the following mappings:
    <servlet>
    <servlet-name> MoLink </servlet-name>
    <servlet-class> MoServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> MoLink </servlet-name>
    <url-pattern> /servlet/Mo </url-pattern>
    </servlet-mapping>
    (c) Deploy the application
    Using command line:
    wdeploy deploy      -u /foo
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\foo-dir
              Foo.war
    (d) Change web-apps.xml file (for picking up ThirdParty.jar)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    You should see something similar to following after successful deployment.
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
    Change it to look like following to pick up the ThirdParty.jar
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
    <class-loader reload-interval="300"
              classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
              delegate="false"/>
    </web-app>
    (e) Change jvm12.conf file (for JNI)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    Add or uncomment the following lines:
    #optional - just helps with instrumenting the jsp and servlet code
    jvm.include.CLASSPATH=1
    jvm.enableDebug=1
    nes.jsp.enabledebug=1
    jvm.trace=7
    jvm.verboseMode=1
    #required for JNI
    java.compiler=NONE
    jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
    jvm.option=-Xrs
    jvm.option=-Xnoagent
    # not sure if this is needed for iPlanet web server
    jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
    (f) Change magnus.conf file (for JNI)
    We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
    iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
    in Path, it didn't work.
    Change Extrapath directive:
    ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    to
    ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    (g) Apply changes from the Web Server Administration Console and Restart the web server.
    You should be able to see the behaviour that you want from your application.
    http://yourserver/foo/foo.jsp
    Hope this was helpful!!!
    Sonu

  • How to go to new jsp from servlet.

    In the results page, if a button is clicked, i go to servlet, then come back to display data from database in another page. It works fine but the problem is that I wnat to open up a new browser and display the target page there and not the results page.
    results.jsp --> click button --> go to servlet --> display data on resultDetails.jsp (same browser window).
    I want resultDetails.jsp in a new browser window.
    my code in results.jsp is:
    <input type = \"button\" onclick = \"location.href = 'Controller.wss?page=RESULT_DETAILS_PAGE&cmd_id="+cmdId+"'\" value = \"see details..\">
    how can i change this. I am using java in jsp and out.println for any html content.
    Thank you in advance. Any help (with/without) examples would be appreciated.
    Bhavna.

    1. Create a jsp (popup.jsp) file with the content you want for the pop up window (eventually read some parameters from the request, if you need)
    2. when creating the resultDetails.jsp generate a JavaScript that opens the pop-up jsp file using someting like:
    <script>
    window.open("popup.jsp?param1=<%=param1%>&param2=<%=param1%>");
    </script>

  • JSPs with custom components will not compile

    All,
    I have written a custom component, but am having trouble getting it to work. When i place it in a jsp or jspx and try to run the application using this control, i get compilation errors:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    [javac] C:\Sun\SDK\domains\domain1\generated\jsp\j2ee-modules\CPIDemo\org\apache\jsp\cpiMain_jsp.java:2053: cannot find symbol
    [javac] symbol : method setPageContext(javax.servlet.jsp.PageContext)
    [javac] location: class cpidemo.wpfRenderer
    [javac] jspxth_cpi_wpf_0.setPageContext(_jspx_page_context);
    [javac] ^
    Generated servlet error:
    [javac] C:\Sun\SDK\domains\domain1\generated\jsp\j2ee-modules\CPIDemo\org\apache\jsp\cpiMain_jsp.java:2054: cannot find symbol
    [javac] symbol : method setParent(javax.servlet.jsp.tagext.Tag)
    [javac] location: class cpidemo.wpfRenderer
    [javac] jspxth_cpi_wpf_0.setParent((javax.servlet.jsp.tagext.Tag) jspxth_webuijsf_panelLayout_2);
    [javac] ^
    Generated servlet error:
    [javac] C:\Sun\SDK\domains\domain1\generated\jsp\j2ee-modules\CPIDemo\org\apache\jsp\cpiMain_jsp.java:2063: cannot find symbol
    [javac] symbol : method doStartTag()
    [javac] location: class cpidemo.wpfRenderer
    [javac] int jspxeval_cpi_wpf_0 = jspxth_cpi_wpf_0.doStartTag();
    [javac] ^
    Generated servlet error:
    [javac] C:\Sun\SDK\domains\domain1\generated\jsp\j2ee-modules\CPIDemo\org\apache\jsp\cpiMain_jsp.java:2064: cannot find symbol
    [javac] symbol : method doEndTag()
    [javac] location: class cpidemo.wpfRenderer
    [javac] if (_jspx_th_cpi_wpf_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
    [javac] ^
    Generated servlet error:
    [javac] C:\Sun\SDK\domains\domain1\generated\jsp\j2ee-modules\CPIDemo\org\apache\jsp\cpiMain_jsp.java:2065: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (cpidemo.wpfRenderer)
    [javac] jspxtagPool_cpi_wpf_ttlValue_rendered_paramList_formWidth_formScript_formName_formHeight_detID_nobody.reuse(_jspx_th_cpi_wpf_0);
    [javac] ^
    Generated servlet error:
    [javac] C:\Sun\SDK\domains\domain1\generated\jsp\j2ee-modules\CPIDemo\org\apache\jsp\cpiMain_jsp.java:2068: reuse(javax.servlet.jsp.tagext.Tag) in org.apache.jasper.runtime.TagHandlerPool cannot be applied to (cpidemo.wpfRenderer)
    [javac] jspxtagPool_cpi_wpf_ttlValue_rendered_paramList_formWidth_formScript_formName_formHeight_detID_nobody.reuse(_jspx_th_cpi_wpf_0);
    [javac] ^
    Generated servlet error:
    [javac] Note: C:\Sun\SDK\domains\domain1\generated\jsp\j2ee-modules\CPIDemo\org\apache\jsp\cpiMain_jsp.java uses unchecked or unsafe operations.
    Generated servlet error:
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 6 errors
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:94)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:384)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:461)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:528)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:507)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:495)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:530)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:412)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:318)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:850)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:697)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:532)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:465)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:353)
    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:413)
    at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:480)
    at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:125)
    at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:285)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:133)
    at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:244)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:184)
    at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:216)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:184)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:276)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
    at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
    After fighting with this for a while, I tried the following:
    1) Copy code from a known-working example into the existing web app
    2) Copy the code for the component et al into the known working example app
    results:
    1) Known working component generates the same compilation errors
    2) everything work correctly
    I have compared the tlds and faces-config.xml files and everything appears to be correct. In both cases, the faces-config.xml files are at version 1.2 and the tlds are at version 2.1
    The only difference i can see is that the not-working web app uses far more libraries than the working example, though i'm not sure why this would be a problem.
    From the not working webapp:
    faces-config.xml
    <?xml version='1.0' encoding='UTF-8'?>
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
    version="1.2">
    <!-- Set default locale and add supported locales here...
    <application>
    <locale-config>
    <default-locale>en</default-locale>
    <supported-locale>de</supported-locale>
    <supported-locale>fr</supported-locale>
    <supported-locale>es</supported-locale>
    </locale-config>
    </application>
    -->
    <component>
    <description>A wrapper for workplace forms viewer</description>
    <display-name>Embedded Form Viewer</display-name>
    <component-type>cpidemo.wpfRenderer</component-type>
    <component-class>cpidemo.wpfRenderer</component-class>
    </component>
    </faces-config>
    cpi.tld
    <?xml version="1.0" encoding="UTF-8"?>
    <taglib version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_1.xsd">
    <tlib-version>1.0</tlib-version>
    <short-name>cpi</short-name>
    <uri>http://www.etechway.com/cpi</uri>
    <!-- A validator verifies that the tags are used correctly at JSP
    translation time. Validator entries look like this:
    <validator>
    <validator-class>com.mycompany.TagLibValidator</validator-class>
    <init-param>
    <param-name>parameter</param-name>
    <param-value>value</param-value>
         </init-param>
    </validator>
    -->
    <!-- A tag library can register Servlet Context event listeners in
    case it needs to react to such events. Listener entries look
    like this:
    <listener>
    <listener-class>com.mycompany.TagLibListener</listener-class>
    </listener>
    -->
    <tag>
    <name>wpf</name>
    <tag-class>cpidemo.wpfRenderer</tag-class>
    <body-content>empty</body-content>
    <attribute>
    <description>A value binding that points to a bean property</description>
    <name>binding</name>
    <deferred-value>
    <type>javax.faces.component.UIComponent</type>
    </deferred-value>
    </attribute>
    <attribute>
    <name>formName</name>
    <required>true</required>
    <rtexprvalue>false</rtexprvalue>
    <deferred-value>
    <type>String</type>
    </deferred-value>
    </attribute>
    <attribute>
    <name>rendered</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    <deferred-value>
    <type>boolean</type>
    </deferred-value>
    </attribute>
    <attribute>
    <name>formScript</name>
    <required>true</required>
    <rtexprvalue>false</rtexprvalue>
    <deferred-value>
    <type>String</type>
    </deferred-value>
    </attribute>
    <attribute>
    <name>detID</name>
    <required>true</required>
    <rtexprvalue>false</rtexprvalue>
    <deferred-value>
    <type>String</type>
    </deferred-value>
    </attribute>
    <attribute>
    <name>ttlValue</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    <deferred-value>
    <type>String</type>
    </deferred-value>
    </attribute>
    <attribute>
    <name>formHeight</name>
    <required>true</required>
    <rtexprvalue>false</rtexprvalue>
    <deferred-value>
    <type>String</type>
    </deferred-value>
    </attribute>
    <attribute>
    <name>formWidth</name>
    <required>true</required>
    <rtexprvalue>false</rtexprvalue>
    <deferred-value>
    <type>String</type>
    </deferred-value>
    </attribute>
    <attribute>
    <name>paramList</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    <deferred-value>
    <type>String</type>
    </deferred-value>
    </attribute>
    </tag>
    </taglib>
    can anyone give me a nudge in the right direction here?
    Thanks in advance!!

    [javac] C:\Sun\SDK\domains\domain1\generated\jsp\j2ee-modules\CPIDemo\org\apache\jsp\cpiMain_jsp.java:2053: cannot find symbol
    [javac] symbol : method setPageContext(javax.servlet.jsp.PageContext)
    [javac] location: class cpidemo.wpfRenderer
    [javac] jspxth_cpi_wpf_0.setPageContext(_jspx_page_context);
    [javac] ^
    Assuming cpidemo.wpfRenderer is your class, does it have the method referenced above?

  • Problem linking jsp with javabeans

    Hey guys,
    I am new at this jsp stuff, but have read a few threads as well as a few tutorials. however, i dont understand why i keep getting this error. any help would be appreciate it!
    i m currently running it off tomcat 4.1, and the hierarchy that i have currently is set like this:
    "xxx/build/array.jsp"
    "xxx/build/WEB-INF/classes/arraymap/javaBeans/ArraysBean.java"
    the content of my jsp is as follows:
    <%@ page import="arraymap.javaBeans.ArraysBean" %>
    <html>
    <head>
         you are in the array page!
    </head>
    <jsp:useBean id="test" class="arraymap.javaBeans.ArraysBean" scope="page"/>
    <body>
    <a href="index.html"> LOG OUT</a>
    <center>
    Please choose one of the following queries:
    </h3>
    </center>
    </body>
    </html>and my simple bean code:
    package arraymap.javaBeans;
    import java.util.*;
    import arraymap.*;
    public class ArraysBean {
        ArrayMapModMain a = ArrayMapModMain.instance();
        public Object[] getArrayTypes()
         return a.getArrayTypes();
    }but i get this error:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 6 in the jsp file: /cds_jsp/build/array.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\cds_jsp\build\array_jsp.java:7: package arraymap.javaBeans does not exist
    import arraymap.javaBeans.ArraysBean;
    ^
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\cds_jsp\build\array_jsp.java:46: package arraymap.javaBeans does not exist
    arraymap.javaBeans.ArraysBean test = null;
    ^
    An error occurred at line: 6 in the jsp file: /cds_jsp/build/array.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\cds_jsp\build\array_jsp.java:48: package arraymap.javaBeans does not exist
    test = (arraymap.javaBeans.ArraysBean) pageContext.getAttribute("test", PageContext.PAGE_SCOPE);
    ^
    An error occurred at line: 6 in the jsp file: /cds_jsp/build/array.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\cds_jsp\build\array_jsp.java:51: package arraymap.javaBeans does not exist
    test = (arraymap.javaBeans.ArraysBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "arraymap.javaBeans.ArraysBean");
    ^
    4 errors
    any idea on why i cant recognize the package? the file is on the tomcat server (the class file is physically there when i manually check it), and i couldnt figure out what i went wrong with either the jsp or hte beans. i have been stuck on this problem for several hours and it is painful sitting in a cube not knowing what is goin on. any help would be GREATLY appreciated! thanks in advance!
    kev

    I copied your files into my environment and it worked fine for me (I had to strip out the ArrayMapModMain stuff to get a compilation though), so it looks like an environment thing as opposed to an issue with your code.
    Possibilities include (shots in the dark):
    1.) The path it showed in the error messages
    "C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\cds_jsp\build\array_jsp.java"
    looks a little funny, mainly the underscore between localhost and cds_jsp. Maybe there's something wrong in your Tomcat config file (see #3).
    2.) Maybe your directory has a permissions issue. Is it readable? Likely not an issue as you're using windows, but it bites me all the time in linux.
    3.) I haven't used Tomcat in a while, but I'll bet it has a config file. Are you sure it's pointing to your WEB-INF/classes dir for your servlets?
    Sorry I can't be of more help.
    jengi

Maybe you are looking for

  • Closing resultsets in loop

    I have code that creates dynamic SQL statements in a loop to search for a value in a table. The Where clause is changed in each iteration of the loop until the value is found or the loop finishes. The code looks something like this: (Sorry for the cr

  • How do I find out what the correct tag information is for a TV series I purchased through the iTunes store?

    Right now I have episodes that should be in their own grouping mixed up with others and I would like to get them seperated.  It's the Doctor Who series if that makes a difference.  Specifically the specials which don't quite fit into a season and wer

  • HELP: ipod not being recognized

    I am using Windows XP and I recently downloaded the new iTunes 7. Now my ipod is not being recogized. When i plug it in, it charges, but a little icon appears on the bottom saying..."One of the USB devices attached to this computer has malfunctioned,

  • SMS app

    I think that there should be a way for you to put the keyboard away whenever you want. Is there a way to do this? Or is there a way to make suggestions for updates?

  • SOAP or HTTP interface

    Hello, I'd like to use Berkeley DB XML remotely. Has anyone released a REST or SOAP wrapper around it ? Thanks, Fabrice