Vector size is zero in jsp though servlet sets it, what is wrong?

servlet sets his attribute
System.out in sevlet shows the values just before thsi command --- request.setAttribute("Names",lvNames);
corresponding JSP code is: The porblem is value of vector size in JSP is zero and tehrfore no loop and no values in combo box...pls help where could be wrong. I am very new to JSPs
<form name="frmAddTx" method="Post" action="MainSrv">
<%
Vector lvNames = new Vector();
%>
table is here
<select name = Name size="1" onChange ="setMsg()">
<% lvNames = (Vector)request.getAttribute("Names");
log("value before any check "+lvNames.size());
if(lvNames.size() != 0)
log("value of "+lvNames.size());
try
for(int i =0;i<lvNames.size();i++)
String temp = (String)lvNames.elementAt(i);
if(lsNewName.equals(temp))
log("selected"+lsNewName);
%>
<option selected"><%=temp%></option>
<%
else
%>
<option><%=temp%></option>
<%
catch(Exception e)
log("error" +e);
%>
</select>

I'm not sure whether the chicken comes before the egg here. Let me see whether I've made an omlette or nuggets:
The JSP displays HTML on the client browser.
There, you have a form named "frmAddTx".
It gets a request from ... somewhere? ... where it gets an array of attributes named "Names" ... from a previous HTML screen? Some HTML form with a "Names" (plural) form element.
Then, when the user submits the form, it calls something called "MainSrv" ... your servlet? ... and passes in the parameter named "Name" (singular).
And then the JSP doesn't have a Vector? HUH??
What am I missing?

Similar Messages

  • Since the IOS 7 update, I can't down size when I'm changing my wallpaper background.  It goes back to the previous size before it will set.  What is wrong?

    I've never had this problem before IOS 7.  My wallpapers don't fit the screen properly and won't resize before saving.  Is this happening to anyone else?  HELP!

    Ok, I just found the solution Thank God
    You see how with the new update the icons move as you tilt the phone to give you that "fancy" 3D look, well because of this the wallpaper gets distorted.
    I turned this option off, and the wallpaper resizing issue went away
    Here is how to turn that dumb 3D option off (which also drains your battery):
    Navigate to the iOS 7 Settings -> General -> Accessibility -> Reduce Motion -> ON
    Yep, that's all.
    Enjoy

  • I'm trying to update my billing information on my iPhone. Everything is correct but it says the month is wrong and has red text even though it's right. what's wrong?

    dtyjk

    Try Here  >  http://support.apple.com/kb/TS1646
    If no joy... Contact iTunes Customer Service and request assistance
    Apple  Support  iTunes Store  Contact Us

  • Database file sometimes gets to zero size and zero file flags

    I have a problem that on my system sometimes single database file gets to a state where it has zero size and zero file flags ( as if set chmod 0 file ).
    My database runs 24/7 and there are multiple agents running at the same time. My database files are backed up and removed from time to time to protect stored data. So I guess that this error could come up when two agents get to backup or recover the database file at the same time. Though, it is hard to find if it is caused by this problem, so I'd like to ask if there is anyone who stumbled on same problem - where one database ends up in state of 0 flags and 0 size.

    Hello, anyone has any tip about this issue?

  • Problem with post and get (jsp to servlet)

    ===jsp code(login.jsp)
    out.println("<form action='servlet/Login' action='post'>");
    out.println("Username <input type='text' name='user' /><br>");
    out.println("Password <input type='password' name='pass' /><br>");
    out.println("<input type='submit' value='Login' /><br></form>");
    the above jsp page is included in another jsp page
    ===jsp code(index.jsp)
    <jsp:include page='login.jsp' flush='true'/>
    when submit is clicked in the login form, the data is send (to Login servlet) in the url string, even though i am using "POST" method in the form.
    the output of request.getMethod() in the Login servlet gives "GET"
    what could be the problem?

    The code you've shown us looks fine. The problem isn't in the form code you've listed. Is the form being included inside another form on index.jsp? Does index.jsp have any forms of it's own? Perhaps you aren't submitting the form you think you are submitting. Or, are you redirecting in your serlvet somewhere? Or are you forwarding the request somehow?
    I agree with the previous post - we need to see the HTML output that index.jsp results in.
    Michael

  • SQLJ JSP and SERVLETS which Environment?

    Hello,
    I am attempting to run the samples on Chapter 5 of the
    following documents with partial success.
    http://technet.oracle.com/docs/products/oracle8i/doc_library/817_
    doc/java.817/a83726/oraext2.htm
    http://download-west.oracle.com/otndoc/oracle9i/901_doc/java.901/
    a90208/oraext.htm#1015820
    1. Do I need the Apache+Jserv environment to run SQLJ and JSP?
    2. What do I need to do run SQLJ on oc4j if possible?
    3. I dont know how to load(?) and/or run this .sqljsp file.
    <%@ page language="sqlj"
    import="sqlj.runtime.ref.DefaultContext,oracle.sqlj.runtime.Oracl
    e" %>
    <HTML>
    <HEAD> <TITLE> The SQLJQuery JSP </TITLE> </HEAD>
    <BODY BGCOLOR="white">
    <% String empno = request.getParameter("empno");
    if (empno != null) { %>
    <H3> Employee # <%=empno %> Details: </H3>
    <%= runQuery(empno) %>
    <HR><BR>
    <% } %>
    <B>Enter an employee number:</B>
    <FORM METHOD="get">
    <INPUT TYPE="text" NAME="empno" SIZE=10>
    <INPUT TYPE="submit" VALUE="Ask Oracle");
    </FORM>
    </BODY>
    </HTML>
    <%!
    private String runQuery(String empno) throws
    java.sql.SQLException {
    DefaultContext dctx = null;
    String ename = null; double sal = 0.0; String hireDate = null;
    StringBuffer sb = new StringBuffer();
    try {
    dctx = Oracle.getConnection("jdbc:oracle:oci8:@", "scott",
    "tiger");
    #sql [dctx] {
    select ename, sal, TO_CHAR(hiredate,'DD-MON-YYYY')
    INTO :ename, :sal, :hireDate
    FROM scott.emp WHERE UPPER(empno) = UPPER(:empno)
    sb.append("<BLOCKQUOTE><BIG><B><PRE>\n");
    sb.append("Name : " + ename + "\n");
    sb.append("Salary : " + sal + "\n");
    sb.append("Date hired : " + hireDate);
    sb.append("</PRE></B></BIG></BLOCKQUOTE>");
    } catch (java.sql.SQLException e) {
    sb.append("<P> SQL error: <PRE> " + e + " </PRE> </P>\n");
    } finally {
    if (dctx!= null) dctx.close();
    return sb.toString();
    %>
    I named above file as test2.sqljsp then I tried these procedures:
    a) $ ojspc test2.sqljsp --these created all the files
    b) $ loadjava -u -v scott/tiger _test2.class -resolve
    this generated:
    initialization complete
    loading : _test2
    creating : _test2
    resolver :
    resolving: _test2
    errors : _test2
    ORA-29521: referenced name test2$_jsp_StaticText could not
    be found
    ORA-29521: referenced name test2SJProfileKeys could not be
    found loadjava: 2 errors
    c) listed the directory and both these files are there but it
    cannot resolve or find it?
    d) I recall reading something about publishjsp command but I have
    to establish a session shell with OSE? this part is very
    confusing and am not sure what to do here.
    e) not sure if i need to publish the loaded class (create a
    procedure? so it can be known to the rest of plsql?)
    A step by step procedure is very much appreciated. fyi.. I
    have Oracle 8.1.7, + oc4j, I can run sqlj from command line
    and class files generated I can run. I can also run JSP and
    servlets on the oc4j accessing the database. It is this SQLJ
    that throws me off balance. If you include Jdeveloper steps
    ro run SQLJ thats also welcome.
    Thanks in advance for kind responses posted.

    In many Model-View-Controller web applications implemented using J2EE, servlets are as controllers to direct the flow between the model and view. While servlets can output HTML code directly, it is much better to use JSPs for the most part. JSPs contain HTML and possibly Java scriptlets. The J2EE container will typically compile JSPs into servlets. While you could use a JSP as a controller, there are drawbacks to that approach. To minimize the amount of Java code in your JSPs, you can either use the tags provided by the JSP spec or use tag libraries written by someone else or yourself. See the JSTL for one such example.
    Also see:
    http://wiki.java.net/bin/preview/Javapedia/MVC
    http://wiki.java.net/bin/view/Javapedia/JavaServerPages

  • If JSP is an extension to Servlets then in what case is one better than ...

    If JSP is an extension to Servlets then in what case is one better than the other... can someone give me an example?

    i wouldn't want to argue with previous poster, because i'm not too over confident with this thing, but i have got an undersatanding that .jsp's are translated to servlates and then compiled...
    so technicaly jsp does exactly what servlet does...
    but when you work with .jsp pages, then you can create web applications more rapitly and indeed there are those special tags that you may define for your self... (though i've never used them -- but then again, i'm just a n00b to JSP technology)

  • How to trap client browser window closing thru JSP or servlets

    How to trap client browser window closing thru JSP or servlets?
    Gunjan

    Hi
    Though some JavaScripts may provide you with solutions , yet there is no reliable way to detect the closing of the browser by the servlet. One way to achieve detection of user quitting a session is setting session timeouts ion the server side. This can be done either through the web.xml file or programatically by setting the session.setMaxInactiveInterval().
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems Inc
    http://www.sun.com/developers/support

  • 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 do I restrict access to JSP or servlet only through SSL Port

    Hi
    I want to restrict the access to few jsp and servlet only through SSL port,
    so how can I block the acces to those jsp and servlet through normal port??? We
    are using weblogic 5.1.
    Any help on this highly appreciated.
    Aruna

    Hi,
    To restrict access(56 bits or less). follow the below steps.
    1. Go to your Webserver instance ServerManager
    2. Click Preferences Tab ------> Encryption Preference
    ------> There disable "DES with 56 bit
    encryption and MD5 message authentication."
    for SSL 2.0 ciphers or SSL3.0 Ciphers. Which ever
    needed.
    3. Save and Restart the Webserver instance.
    The above steps are for 4.x version.
    Thanks,
    Daks.

  • Getting to next JSP from Servlet

    I am getting a 404 when I try to redirect from my servlet to an error page. The code that I am testing is....
    catch (SQLException es)
    LOG.error("Unexpected error in Login.createUser.Error
    message = " + es);
    session.setAttribute(Constants.MESSAGE, es.getMessage());
    session.setAttribute(Constants.ERROR_TITLE, "Login error: " + Constants.SQL_ERROR);
    resp.sendRedirect(Constants.ERROR_PATH);
    I have a compiled java class called Constants where the ERROR_PATH is defined as
    /** Constant name used in obtaining the path to the error page. */
    public static final String ERROR_PATH = "/Jsp/error.jsp";
    My JSP pages are located at the root...
    myapp
    ....Jsp
    ....WEB-INF
    ........classes
    My web.xml looks like this
    <servlet>
    <servlet-name>errorPage</servlet-name>
    <jsp-file>/Jsp/errorPage.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
    <servlet-name>error</servlet-name>
    <url-pattern>/Jsp/error.jsp</url-pattern>
    </servlet-mapping>
    Can anyone point me in the right direction....Thanks

    I tend to use a utility method called redirectToResource in particular to redirect from any servlet to any JSP :
    /** This method will still work when the server is configured to
    *   listen to  port 80 rather than port 8080 (default in Tomcat)
    public void redirectToResource (HttpServletRequest req,
                                     HttpServletResponse resp,
                                  String resourceName)
                         throws ServletException, IOException
       int serverPort    = req.getServerPort();
       String scheme     = req.getScheme();
       String serverName = req.getServerName();
       StringBuffer urlBuffer = new StringBuffer(40);
       urlBuffer.append(scheme + "://" + serverName);
       urlBuffer.append(":" + serverPort);
       urlBuffer.append(resourceName);
        String location = resp.encodeRedirectURL(urlBuffer.toString());
        resp.sendRedirect(location);
    }

  • Need help in JSP and Servlets

    Hi friends,
    [please forgive me if i am posting this in the wrong forum, all seems same to a fresher]
    Now, to my problem..i need a suggestion, a way or a method to implement the following!
    I am supposed to create a servlet that reads data from oracle database. Once i retrive the data (for example: 6 rows of a table having 4 attributes), i am supposed to pass this data to a JSP page where the data has to be formatted and displayed properly. If i call the same servlet from a different JSP, i should be able to access the data in that JSP and format it in a different way. How do i pass the data to JSP? what method i can use to achieve this task?
    Note: I already know about PrintWriter pw = response.getWriter(); and then printing the formated HTML page..but i want to keep the formatting to JSP part and send only the data part that i can access in JSP
    Thanks in adavance

    arun_ramachandran wrote:
    [please forgive me if i am posting this in the wrong forum, all seems same to a fresher]Then you should learn to be more observant - after all, we have JSP and Servlet fora, further down the list. :)
    I am supposed to create a servlet that reads data from oracle database. Once i retrive the data (for example: 6 rows of a table having 4 attributes), i am supposed to pass this data to a JSP page where the data has to be formatted and displayed properly. If i call the same servlet from a different JSP, i should be able to access the data in that JSP and format it in a different way. How do i pass the data to JSP? what method i can use to achieve this task? You can store the data in your session object. You can even use JavaBeans and the jsp:usebean tag.
    [http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html]
    Note: I already know about PrintWriter pw = response.getWriter(); and then printing the formated HTML page..but i want to keep the formatting to JSP part and send only the data part that i can access in JSPA wise approach - I wish more prople woiuld be as thoughtful.

  • How can i upload a image file to server by using jsp or servlet.

    Hi,
    I m gurumoorthy. how can i upload a image file to server by using jsp or servlet without using third party API. pls anyone send me atleast outline of the source code.
    Pls send me anyone.
    Regards,
    Gurumoorthy.

    I'm not an applet programmer so I can't give you much advice there.
    If you want to stream the file from the server before it's entirely uploaded, then I don't believe you can treat it like a normal file. If you're just wanting to throw it up there and then listen to it, then you can treat it like a normal file.
    But again, I'm not entirely certain. You might be able to stream the start of the file from the server while you're still uploading the end of it, but it probably depends on what method you're using to do the transfer.

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

Maybe you are looking for

  • Photoshop cs6 psd saved file video display is degraded from original imported file

    I have had some 16mm film converted to avi 1900 by 1080 pixels, 72 pixels/inch. Photoshop displays it ok. Then when I save the file as a psd and open it again the quality of the video displayed is deteriorated from the origional. Then no matter how i

  • Adobe Air 3.0 iOS streaming H264/Speex over RTMP -- No Video

    Problem: H264/Speex RTMP stream from Flash Media Server doesn't display video.  Audio plays fine. Conditions: Adobe Air 3.0 iOS device (iPad 2, iOS4.3) App settings: <renderMode>direct</renderMode> Flash Builder 4.5.1 compiler settings: -swf-version=

  • Disk Utility refuses to copy 164 GB to a 318 GB volume.

    Hello, I use Disk Utility (stand alone, on a USB key) to make backups of my system disk to an external disk and then transfer it from my home system to a MacBook and vice-versa when I need to travel. Recently, I upgraded from 10.9.2 to 10.9.3 and, no

  • How can I get the full-length ringtone "Calypso" back?

    I recently updated my iPhone 4 to iOS 5. In iOS 5, Apple truncated the ringtone "Calypso." I would like to have the full-length ringtone back, as it is very special to me. Is there any way to make this happen? A solution to this problem will be IMMEN

  • How to convert website files to domain file for edit in iWeb

    I have three sites up that I created using iWeb. My hard drive crashed and I hadn't backed up my files. Through ftp, I've downloaded all the files off my websites. Is it possible to create a 'Domain' file using the files I've downloaded? I have every