Bean value forward to servlet

Hi all,
i have bean package cedars;
import java.util.Hashtable;
import java.util.*;
public class FormBean {
      private String name = null;
      private String stuNumber = null;
      private String facultyName= null;
      private String quesOne = null;
      private String quesTwo = null;
      private String quesThree = null;
      private String quesFour= null;
      private String quesFive= null;
      private String quesSix= null;
      private String quesSeven= null;
      private String quesEight= null;
      private String quesNine= null;
      private String quesTen= null;
      private String quesEleven= null;
      private String quesTwelve= null;
      private String quesThirteen= null;
      private String quesFourteen= null;
      private String quesFifteen= null;
      private String quesSixteen= null;
      private String quesSeventeen = null;     
      private String quesEighteen=null;
      private String quesNineteen=null;
      private String quesTwenty=null;
      private String quesTwentyOne=null;
      private Hashtable errors = new Hashtable();
      public boolean validate() {
              boolean allOk=true;
              if (stuNumber.equals("")|| stuNumber.length() !=10) {
                  errors.put("stuNumber","Please enter a valid student Number");
                  stuNumber="";
                  allOk=false;
                } else {
                    try {
                        int x = Integer.parseInt(stuNumber);
                      } catch (NumberFormatException e) {
                        errors.put("stuNumber","Please enter a valid student Number");
                        stuNumber="";
                        allOk=false;
                }//else
              return allOk;        
      public String getErrorMsg(String s) {
              String errorMsg =(String)errors.get(s.trim());
              return (errorMsg == null) ? "":errorMsg;
     public FormBean () {
          again(); 
     /* Name */
       public String getName() {
         return (this.name);
       public void setName(String name) {
         this.name = name;
       /* Student number */
       public String getStuNumber(){
         return (this.stuNumber);
       public void setStuNumber(String stuNumber){
         this.stuNumber = stuNumber;
       /* gender */
       private String gender= null;
       public String getGender(){
         return (this.gender);
       public void setGender(String gender) {
         this.gender = gender;
       /*college*/
       public String getFacultyName(){
         return (this. facultyName);
       public void setFacultyName(String  facultyName){
         this. facultyName=facultyName;
       /*degree*/
       String degree=null;
       public String getDegree() {
              return (this.degree);
       public void setDegree(String degree){
         this.degree =degree;
       /* year */
       private String year = null;
       public String getYear() {
         return (this.year);
       public void setYear(String year){
         this.year = year;
       /*question one */
       public String getQuesOne() {
         return (this.quesOne);
       public void setQuesOne(String quesOne){
         this.quesOne = quesOne;
       /*question two */
       public String getQuesTwo() {
         return (this.quesTwo);
       public void setQuesTwo(String quesTwo){
         this.quesTwo = quesTwo;
       /*question Three */
       public void setQuesThree(String quesThree){
         this.quesThree = quesThree;
       /*question four */
       public String getQuesFour() {
         return (this.quesFour);
       public void setQuesFour(String quesFour){
         this.quesFour = quesFour;
       /*question five */
       public String getQuesFive() {
         return (this.quesFive);
       public void setQuesFive(String quesFive){
         this.quesFive = quesFive;
       /*question six */
       public String getQuesSix() {
         return (this.quesSix);
       public void setQuesSix(String quesSix){
         this.quesSix =quesSix;
       /*question seven */
       public String getQuesSeven(){
         return (this.quesSeven);
       public void setQuesSeven(String quesSeven){
         this.quesSeven =quesSeven;
       /*question Eight */
       public String getQuesEight() {
         return (this.quesEight);
       public void setQuesEight(String quesEight){
         this.quesEight =quesEight;
       /*question Nine */
       public String getQuesNine() {
         return (this.quesNine);
       public void setQuesNine(String quesNine) {
         this.quesNine =quesNine;
       /*question Ten */
       public String getQuesTen(){
         return (this.quesTen);
       public void setQuesTen(String quesTen){
         this.quesNine =quesTen;
       /*question Eleven*/
       public String getQuesEleven(){
         return (this.quesEleven);
       public void setQuesEleven(String quesEleven) {
         this.quesEleven =quesEleven;
       /* question Twelve*/
       public String getQuesTwelve(){
         return (this.quesTwelve);
       public void setQuesTwelve(String quesTwelve) {
         this.quesTwelve =quesTwelve;
       /* question Thirteen**/
       public String getQuesThirteen() {
         return (this.quesThirteen);
       public void setQuesThirteen(String quesThirteen) {
         this.quesThirteen =quesThirteen;
       /*question Fourteen*/
       public String getQuesFourteen() {
         return (this.quesFourteen);
       public void setQuesFourteen(String quesFourteen) {
         this.quesFourteen =quesFourteen;
       /* question Fifteen*/
       public String getQuesFifteen(){
         return (this.quesFifteen);
       public void setQuesFifteen(String quesFifteen) {
         this.quesFifteen =quesFifteen;
      /* question Sisteen*/
       public String getQuesSixteen(){
         return (this.quesSixteen);
       public void setQuesSixteen(String quesSixteen) {
         this.quesSixteen =quesSixteen;
      /* question Seventeen */
       public String getQuesSeventeen (){
         return (this.quesSeventeen );
       public void setQuesSeventeen (String quesSeventeen ) {
         this.quesSeventeen=quesSeventeen ;
       /* question Eighteen*/
       public String getQuesThree(){
         return (this.quesThree);
     public String getQuesEighteen (){
              return (this.quesEighteen );
     public void setQuesEighteen(String quesEighteen ){
              this.quesEighteen =quesEighteen ;
       /*question Nineteen*/
     public String getQuesNineteen(){
         return (this.quesNineteen );
      public void setQuesNineteen(String quesNineteen ){
           this.quesNineteen =quesNineteen ;
     /*Twenty*/
  public String getQuesTwenty(){
     return (this.quesTwenty );
  public void setQuesTwenty(String quesTwenty ){
     this.quesTwenty =quesTwenty ;
     /*Twenty-One*/
public String getQuesTwentyOne(){
return (this.quesTwentyOne );
public void setQuesTwentyOne(String quesTwentyOne ) {
      this.quesTwentyOne =quesTwentyOne ;     }
public void setErrors(String key, String msg) {
         errors.put(key,msg);
       public void again(){                               
              setName("");
              setStuNumber("");
              setGender("");
              setFacultyName("");
              setDegree("");            
              setYear("");           
              setQuesOne("");
              setQuesTwo("");
              setQuesThree("");
              setQuesFour("");
              setQuesFive("");
              setQuesSix("");
              setQuesSeven("");
              setQuesEight("");
              setQuesNine("");
              setQuesTen("");
              setQuesEleven("");
              setQuesTwelve("");
              setQuesThirteen("");
              setQuesFourteen("");
              setQuesFifteen("");     
              setQuesSixteen("");
              setQuesSeventeen("");
              setQuesEighteen("");
              setQuesNineteen("");
              setQuesTwenty("");
              setQuesTwentyOne("");
}and process.jsp
%@ page import="java.util.*" %>
<html>
  <head>
<jsp:useBean id="formHandler" class="cedars.FormBean" scope="request">
<jsp:setProperty name="formHandler" property="*"/>
</jsp:useBean>
<%
   if (formHandler.validate()) {%>
<jsp:forward page="/servlet/Insert"/>
<% } else { %>
<jsp:forward page="/resubmit.jsp"/>
<% } %>
</body>
</html>row now the forward to resubmit.jsp is work , but forward to <jsp:forward page="/servlet/Insert"/>
is not work , why?
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import javax.sql.*;
import pool.ConnectionPool;
public class Insert extends HttpServlet {   
    Connection conn = null;
    Statement stmt = null;
     ResultSet rs = null;
     PreparedStatement ps = null;
     ConnectionPool connectionPool = null;
   * We want to initialized the JDBC connections here
    public void init()
             String jdbcDriver = "com.mysql.jdbc.Driver";
             String dbURL ="jdbc:mysql://localhost/survey?";
             try
             //instantiate the connection pool object by passing the
             //jdbc driver, database URL, username, and password
             connectionPool = new ConnectionPool(jdbcDriver, dbURL,
             "root","mysql");
             //specify the initial number of connections to establish
             connectionPool.setInitialConnections(5);
             //specify number of incremental connections to create if
             //pool is exhausted of available connections
             connectionPool.setIncrementalConnections(5);
             //specify absolute maximum number of connections to create
             connectionPool.setMaxConnections(20);
             connectionPool.createPool(); //create the connection pool
             catch(Exception e)
             System.out.println("Error: " + e);
/** Destroys the servlet.
    public void destroy() {
    public void doGet(
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {  
       }// end of DoGet
public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {    
     res.setContentType("text/html");
     PrintWriter out = res.getWriter(); 
   try {        
    //Get the incoming data parameters from the client         
           String  name=req.getParameter("name");
           String  stuNumber=req.getParameter("stuNumber");
           String  gender=req.getParameter("gender");
           String  facultName=req.getParameter("facultyName");
           String  degree=req.getParameter("degree");          
           String  year=req.getParameter("year");        
           String  quesOne=req.getParameter("quesOne");
           String  quesTwo=req.getParameter("quesTwo");
           String  quesThree=req.getParameter("quesThree");
           String  quesFour=req.getParameter("quesFour");
           String  quesFive=req.getParameter("quesFive");
           String  quesSix=req.getParameter("quesSix");
           String  quesSeven=req.getParameter("quesSeven");
           String  quesEight=req.getParameter("quesEight");
           String  quesNine=req.getParameter("quesNine");
           String  quesTen=req.getParameter("quesTen");
           String  quesEleven=req.getParameter("quesEleven");
           String  quesTwelve=req.getParameter("quesTwelve");
           String  quesThirteen=req.getParameter("quesThirteen");
           String  quesFourteen=req.getParameter("quesFourteen");
           String  quesFifteen=req.getParameter("quesFifteen");
           String  quesSixteen=req.getParameter("quesSixteen");
           String  quesSeventeen=req.getParameter("quesSeventeen");
           String  quesEighteen=req.getParameter("quesNineteen");
           String  quesNineteen=req.getParameter("quesNineteen");
           String  quesTwenty=req.getParameter("quesTwenty");
           String  quesTwentyOne=req.getParameter("quesTwentyOne");
           String ErrMsg="";
           String found="";
           HttpSession userSession = req.getSession(true);   
           HttpSession session=req.getSession();
           for (int i=0; i<stuNumber.length(); i++){              
                char ch=stuNumber.charAt(i);
               if (Character.isLetter(ch)){
                 found =found +ch;}
            * check the empty fields
                   if (stuNumber.equals("") ||                    
                            ((found.length()>=1 ))||                         
                            (stuNumber.length()!=10))
                       out.println("<html>");                        
                       out.println("<body bgcolor=\"#FFFFFF\">");
                        out.println("<center>");
                       out.println("<strong> Valid Studend number is require!<strong>");
                       out.println("</center>");
                       out.println("</body>");                        
                       out.println("</html>");
                       out.close();
                   Integer q1=0, q2=0, q3=0, q4=0, q5=0, q6=0, q7=0, q8=0,q9=0,q10=0;
                   Integer q11=0, q12=0, q13=0, q14=0, q15=0, q16=0, q17=0, q18=0, q19=0, q20=0,q21=0;
                     q1 = Integer.valueOf(quesOne);
                     q2 = Integer.valueOf(quesTwo);
                     q3 = Integer.valueOf(quesThree);
                     q4 = Integer.valueOf(quesFour);
                     q5 = Integer.valueOf(quesFive);
                     q6 = Integer.valueOf(quesSix);
                     q7 = Integer.valueOf(quesSeven);
                     q8 = Integer.valueOf(quesEight);
                     q9 = Integer.valueOf(quesNine);
                      q10 = Integer.valueOf(quesTen);
                      q11 = Integer.valueOf(quesEleven);
                      q12 = Integer.valueOf(quesTwelve);
                      q13 = Integer.valueOf(quesThirteen);
                      q14 = Integer.valueOf(quesFourteen);
                       q15 = Integer.valueOf(quesFifteen);
                       q16 = Integer.valueOf(quesSixteen);
                        q17 = Integer.valueOf(quesSeventeen);
                         q18 = Integer.valueOf(quesEighteen);
                         q19 = Integer.valueOf(quesNineteen);
                         q20 = Integer.valueOf(quesTwenty);
                          q21 = Integer.valueOf(quesTwentyOne);
                   Integer total=0;
                   total=q1+q2+q3+q4+q5+q6+q7+q8+q9+q10+q11+q12+q13+q14+q15+q16+q17+q18+q19+q20+q21;
                   /*if form is valid, catch the session*/
                     userSession.setAttribute("stuNumber",stuNumber );
                       userSession.setAttribute("quesOne",quesOne); 
                       userSession.setAttribute("quesTwo",quesTwo); 
                       userSession.setAttribute("quesThree",quesThree); 
                       userSession.setAttribute("quesFour",quesFour); 
                       userSession.setAttribute("quesFive",quesFive); 
                       userSession.setAttribute("quesSix", quesSix); 
                       userSession.setAttribute("quesSeven",quesSeven); 
                       userSession.setAttribute("quesEight",quesEight); 
                       userSession.setAttribute("quesNine",quesNine); 
                       userSession.setAttribute("quesTen",quesTen); 
                       userSession.setAttribute("quesTwelve", quesTwelve);
                       userSession.setAttribute("quesEleven",  quesEleven);
                       userSession.setAttribute("quesThirteen", quesThirteen);
                       userSession.setAttribute("quesFourteen", quesFourteen);
                       userSession.setAttribute("quesFifteen",   quesFifteen);              
                      userSession.setAttribute("quesSixteen",  quesSixteen);             
                      userSession.setAttribute("quesSeventeen",quesSeventeen);
                      userSession.setAttribute("quesEighteen", quesEighteen);
                      userSession.setAttribute("quesNineteen",quesNineteen);
                      userSession.setAttribute("quesTwenty",quesTwenty);
                       userSession.setAttribute("quesTwentyOne",quesTwentyOne);
                       userSession.setAttribute("total",total);
                        RequestDispatcher disp;
                        disp = getServletContext().getRequestDispatcher("/confirmation.jsp");
                        disp.forward(req, res);      
                      //get free connection from pool
                        conn =connectionPool.getConnection();      
            //select a database
           // conn.setCatalog("survey");
            /* add this part*/
            stmt = conn.createStatement();
            rs = stmt.executeQuery("SELECT*  FROM survey where stuNumber='"+stuNumber+"'");
                int count =0;//how many rows we can find.
                while (rs.next()){
                    count++;
                connectionPool.returnConnection(conn);
             if(count<1){                       
                      conn.setAutoCommit(false);
                    String  sql="insert into survey(name, stuNumber, gender,facultyName,degree, year, quesOne, quesTwo, quesThree, quesFour, quesFive, quesSix,quesSeven, quesEight, quesNine,quesTen,quesEleven, quesTwelve, quesThirteen, quesFourteen,quesFifteen, quesSixteen, quesSeventeen, quesEighteen, quesNineteen, quesTwenty, quesTwentyOne)";
                                         sql+="value(?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                          ps = conn.prepareStatement(sql);
                          stmt = conn.createStatement();
                           ps.setString(1, name);
                          ps.setString(2, stuNumber);
                          ps.setString(3, gender);
                          ps.setString(4, facultName);
                          ps.setString(5, degree);
                          ps.setString(6, year);
                          ps.setString(7, quesOne);
                          ps.setString(8, quesTwo);
                          ps.setString(9, quesThree);
                          ps.setString(10, quesFour);
                          ps.setString(11, quesFive);
                          ps.setString(12, quesSix);
                          ps.setString(13, quesSeven);
                          ps.setString(14, quesEight);
                          ps.setString(15, quesNine);
                          ps.setString(16, quesTen);
                          ps.setString(17, quesEleven);
                          ps.setString(18, quesTwelve);
                          ps.setString(19, quesThirteen);
                          ps.setString(20, quesFourteen);
                          ps.setString(21, quesFifteen);
                          ps.setString(22, quesSixteen);
                          ps.setString(23, quesSeventeen);
                          ps.setString(24, quesEighteen);
                          ps.setString(25, quesNineteen);
                          ps.setString(26, quesTwenty);
                          ps.setString(27, quesTwentyOne);
                          ps.executeUpdate();                   
                     conn.commit();
                  conn.setAutoCommit(true);   
                  connectionPool.returnConnection(conn);
             /* doing the update*/
             else{
                  conn.setAutoCommit(false);
                  String sql2 = "UPDATE survey set name=?";
                    sql2+= ", gender=?,facultyName=?,degree=?, year=?, quesOne=?, questwo=?, quesThree=?, quesFour=?, quesFive=?, quesSix=?,";
                    sql2+= "quesSeven=?,quesEight=?, quesNine=?, quesTen=?,quesEleven=?, quesTwelve=?, quesThirteen=?, quesFourteen=?";
                    sql2+=",quesFifteen=?, quesSixteen=?, quesSeventeen=?, quesEighteen=?, quesNineteen=?, quesTwenty=?, quesTwentyOne=?";
                    sql2+="WHERE stuNumber=?";
                    ps = conn.prepareStatement(sql2);
                    stmt = conn.createStatement();
                     ps.setString(1, name);                    
                      ps.setString(2, gender);
                      ps.setString(3, facultName);
                      ps.setString(4, degree);
                      ps.setString(5, year);
                      ps.setString(6, quesOne);
                      ps.setString(7, quesTwo);
                      ps.setString(8, quesThree);
                      ps.setString(9, quesFour);
                      ps.setString(10, quesFive);
                      ps.setString(11, quesSix);
                      ps.setString(12, quesSeven);
                      ps.setString(13, quesEight);
                      ps.setString(14, quesNine);
                      ps.setString(15, quesTen);
                      ps.setString(16, quesEleven);
                      ps.setString(17, quesTwelve);
                      ps.setString(18, quesThirteen);
                      ps.setString(19, quesFourteen);
                      ps.setString(20, quesFifteen);
                      ps.setString(21, quesSixteen);
                      ps.setString(22, quesSeventeen);
                      ps.setString(23, quesEighteen);
                      ps.setString(24, quesNineteen);
                      ps.setString(25, quesTwenty);
                      ps.setString(26, quesTwentyOne);
                      ps.setString(27,  stuNumber);
                      ps.executeUpdate();                   
               conn.commit();
             conn.setAutoCommit(true);   
             connectionPool.returnConnection(conn);
    }catch (SQLException e) {
          throw new ServletException(e);
     finally {
          try {
               if(rs != null)
                    rs.close();
               if(stmt != null)
                    stmt.close();
               if(ps != null)
                    ps.close();
               if(conn != null)
                    conn.close();
               connectionPool.returnConnection(conn);
          } catch (SQLException e) {}
} // end doPost
public String getServletInfo()
    return "A Simple Servlet";
}// end of ContrInsert

The way to do this with a JSP is use an HTML Form tag to pass all the information on to a new page, and save the new info while creating this new page

Similar Messages

  • ADF BC how to access session backing bean value in servlet

    Hi everyone,
    How do I access session backing bean value in a servlet?

    Frank, thanks for your reply.
    I'm not sure how I can incorporate this example into my situation. Let me explain more detail about my problem.
    "servlet" in my post here actually means a custom servlet I wrote for rendering an image that is stored in db as ordimage. In this servlet, I get hold of my appmodule by using Configuation.createRootApplicationModule(). By doing so (If I'm not wrong) a new database session/connection is created. What I'm going to achieve is set application context for this new session/connection in db with the data stored in a session backing bean in the view layer.
    I can pass the required data to the servlet thru url parameter, but I don't want to do it this way for the reason that the data may contains sensitive information.
    I hope I have explained myself well.
    Message was edited by:
    bsmt

  • Froward  bean value to servlet

    if I want to forward bean value to servlet I use
    <%@ page import="java.util.*" %>
    <html>
      <head>
    <jsp:useBean id="formHandler" class="cedars.FormBean" scope="request">
    <jsp:setProperty name="formHandler" property="*"/>
    </jsp:useBean>
    <%
       if (formHandler.validate()) {%>
    <jsp:forward page="/servlet/Insert"/>
    <% } else { %>
    <jsp:forward page="/resubmit.jsp"/>
    <% } %>
    </body>
    </html> is that right?
    why i keep get error message like NullPointerException on <jsp:forward page="/servlet/Insert"/>
    my beab local on cedars.FormBean, my Insert.java in WEB-INF/classes
    thank you for the help

    Hi,
    don't think it will execute EL this way. However,you should be able to execute JavaScript (what you should keep in mind though is that any DOM manipulation on AMX page rendering is a risk and can put you into trouble). What is the HTML you want to insert (and to what extend do you control the metadata tags added to the AMX page this way? Wouldn't it be possible to add the content using AMX components?
    Frank

  • Can't retrieve bean value from jsp!

    Here's the chain of events for my web app:
    JSP form (get info from user) -> forwarding jsp (uses bean to save info submitted to form)-> servlet (retrieves info from DB) -> JSP (presents DB info to user by populating values in text fields from original form)
    Right now, I can access all the values submitted to the first JSP from my servlet. However, after my servlet retrieves the info from a db and stores it in a bean and forwards the request (using requestdispatcher) to the 2nd JSP, I can't get the values from the bean from the 2nd jsp. I was able to use the bean to store the information submitted to the original JSP, however.
    Here's some relevant code:
    FROM FORWARDING JSP (which saves user-submitted info in bean)
    <jsp:useBean id="fxFormBean" class="fxmatcher.FxFormBean" scope="request"/>
    <jsp:setProperty name="fxFormBean" property="*" />
    <jsp:forward page="/FxMatcher" />
    FROM LAST JSP (which should populate form fields)
    header stuff:
    <jsp:useBean id="fxFormBean" class="fxmatcher.FxFormBean" scope="session"/>
    info retrieval:
    <INPUT TYPE="text" NAME="fx_key" value="<%= fxFormBean.getFx_key() %>">
    I wrote this JSP based on the example given here: http://www.jsptut.com/Editing.jsp, but I'm not getting the value from the bean. The result JSP just has value="".
    I'm pretty sure that my servlet is saving the info to bean correctly, but here's the code anyways:
    //retrieves info from DB
    FxFormBean fx = (FxFormBean) request.getAttribute("fxFormBean");
    fx.setFx_key (traderKey);
    fx.setAa_block(agent_block);
    fx.setAddition_to (additional_to);
    log("trader key: [" + fx.getFx_key() + "]"); //debugging code
    My debugging code did print out the correct info, so I don't think there's anything wrong with the bean or the servlet.
    I would appreciate any help. Thank you very much.

    The first JSP puts the bean in the request, the servlet retrieves the bean from the request and updates it but in the second JSP you set the scope to session:
    <jsp:useBean id="fxFormBean" class="fxmatcher.FxFormBean" scope="session"/>
    So the second JSP is looking in the wrong place for your bean. Change the scope in the second JSP to request:
    <jsp:useBean id="fxFormBean" class="fxmatcher.FxFormBean" scope="request"/>

  • Instantiate a bean from within a Servlet

    I am attempting to instantiate a bean from within a Servlet. Basically, I would like to set my bean properties from within a central controlling servlet, then call a worker class to take care of my database insert. The worker class would get its values from the bean.
    Does this sound reasonable? I'm sure this is quite possible and very easy to pull off, however I can't seem to find a single example. An example would be greatly appreciated.

    Hi,
    I have read what you have done.
    Now in the servlet add something like
    HttpSession ses=request.getSession(true);</stro
    ses.addAttribute("user","your Bean name");*
    in the JSP get this atribute by
    session.getAttribute("user");+
    Anyway, how have you configured your server? I am using a Bean Class and trying to instantiate in a sevlet. An exception is occuring.
    import mypack.User; //it is nicely imported*
    //in the doPOST() method
    User user=new User();+ //trying to instantiate
    it is giving an Exception. Kindly help.

  • How do I update a bean value from an AJAX call?

    Hi all,
    How do I update a bean value from an AJAX call? I suppose I could write a servlet to do it. However, this seems like a common problem, so I was wondering if there was some built in solution.
    Thanks,
    Grae
    Edited by: caalip2 on Mar 30, 2010 1:07 PM

    caalip2 wrote:
    Raymond
    Basically, I would user the following. The first choice for IE, the second for Firefox.
    new ActiveXObject("Microsoft.XMLHTTP");
    new XMLHttpRequest();
    GraeDon't do this to yourself. If it were that easy there wouldn't be AJAX frameworks for JSF. Find one you like and use it. I've used a4j (part of RichFaces) successfully.

  • How to get the value from a servlet?

    Hello guys:
    how can i get the value from a servlet on my jsp page,for example return a boolean variable from a servlet
    which API to use?
    thanks

    Hi
    There is no specific API for this, call the method of the servlet which returns the required value in your JSP page.
    Thanks
    Swaraj

  • How to assign bean value to a local variable in JSP using struts.

    Hi everybody!
    I've a problem that puzzled me on how to assign a bean value to a local variable like String in JSP using struts.
    we can have someting like this to display the value
    <bean:write name="detailService" property="status" />or
    <bean:define id="theStatus" name="detailService" property="status"/>
         This is country: <%=theStatus%>but an error occured when I tried like this:
    String currentStatus = "<bean:define id="theStatus" name="detailService" property="status"/>";
    or
    String currentStatus = "<bean:write name="detailService" property="status" />";Is there a way to do this?.....
    Any help pretty much appreciated

    Java != JSP.
    The <bean:define> and <bean:write> tags are custom tags meant to appear in the HTML section of a JSP file, as opposed to the scriptlet section. They actually get turned into java code as part of the translation process.
    The <bean:write> tag naturally just writes out what you tell it to.
    The <bean:define> tag defines a local variable, and gives it a value.
    this should do it.
    <bean:define id="theStatus" name="detailService" property="status" type="java.lang.String"/>
    <%
      String currentStatus = theStatus;
    %>With the advent of JSTL, you shouldn't really need to use scriptlet code anymore. Personally I am for 0% scriptlet code in any jsp I write.

  • How to call the form bean value on jsp withthe help of jstl tag

    hi
    all friends
    i am working in struts & i use jstl tag in jsp. i have one problem rise is how to call the form bean value in jsp page by using jstl tag.
    i now how to retrive the value through jsp:logic
    eg. <logic:empty name="userListForm" property="users">
    NO USER FOUND
    </logic:empty>
    see * userListForm mean formbaen name.
    * users means collection object.
    so how can i write above e.g in jstl

    You use the jstl core:if or core:choose combined with the EL:
    <c:if test="${empty users.userListForm}">
    NO USERS FOUND
    </c:if>I suggest you lookup the jsp expression language (EL) using google, it's very powerful.

  • Problem in passing  HTML form values to a servlet in NetBean IDE

    hi there,
    When i click the submit button of the HTML File(with two textFields with values) the value received in the corresponding servlet is null , I used the get method to pass value so i was able to see the values in the URL but when i print the value in the Servlet it display null. I have verfied the web.xml to cheak the servlet mapping is right .Servlet mapping are perfect but i am not getting the value in the next page. Kindly give your suggestions.
    Thanks in advace

    Try this in your servlet.
    HttpSession session = request.getSession(true);     
    System.out.println(request.getParameter("xxxxx").toString());
    xxxx is the parameter name..
    Doesn't this work?

  • Passing form values to a Servlet

    I am trying to pass form value to a servlet once the user presses the submit button. How can I get access to the form values?
    Thanks

    Try this in your servlet.
    HttpSession session = request.getSession(true);     
    System.out.println(request.getParameter("xxxxx").toString());
    xxxx is the parameter name..
    Doesn't this work?

  • Using bean value in NLS text entry

    Hi all,
    Is there a way I can use the JHeadstart NLS function like
    title="#{nls['HOME_PAGE_TITLE']}"
    and include a bean value in the title
    eg " Welcome #{jhsUser.userId} to my wonderful application".
    I use JHS_TRANSLATIONS to store my text - if I enter the value as above, the jhsUser expression does not get rendered
    Cheers,
    Brent

    Just after posting this message I saw that the exact same thing had been done in the page I had just generated !
    So, the answer is to use this
    text="#{nls['HOME_WELCOME_MSG: #{jhsUser.displayName}']}"Is there a way to inject this in through the JHeadstart application definition ? If I place the value in the Display Title property it further wraps the text with extra nls and {}.
    Is my only option to create a custom template for grouTemplate.vm ?
    Cheers,
    Brent

  • Problem exchanging values between a Servlet and Thread???

    Hi Everybody,
    I have got a problem exchanging values between a Servlet and a Thread...
    The actual thing will go like this
    I take a request from JSP which is served by a servlet..
    A thread is invoked in the servlets into which the parameter values taken from JSP page is sent...
    In between the thread needs to be suspended for a moment, relieve the control back to the servlet and then come back with the new values modified in the servlet...
    How is this achieved?
    Please give ur suggestions regarding this...
    Thanks in advance

    I really have no clue how you can use URLConnection to do that!
    Could you please explain in the following scenario how it can help me as an alternative solution to the following:
    Non-Servlet A continously running & saving to some prop regularly
    --> servlet B reads prop file regularly --> display continously on a jsp file
    I wish I could do a servlet A --> servlet B-- > display jsp scenario but I do not know how to have servlet A continously running while keep the servlet B interacting with the jsp.

  • Bean value to amx:verbatim to make HTML dynamic ADF Mobile

    Hi guys,
    As using <amx:verbatim> to insert HTML directly in AMX page for ADF Mobile.
    <amx:verbatim id="v1">
          #{PolicySummaryBean.currentSVG1}
        <![CDATA[
    #{PolicySummaryBean.currentSVG2}
    ]]>
        </amx:verbatim>
    Btw I tried to using bean value as EL to produces HTML from bean and seems didn't work
    How to make it possible ?
    Thanks

    Hi,
    don't think it will execute EL this way. However,you should be able to execute JavaScript (what you should keep in mind though is that any DOM manipulation on AMX page rendering is a risk and can put you into trouble). What is the HTML you want to insert (and to what extend do you control the metadata tags added to the AMX page this way? Wouldn't it be possible to add the content using AMX components?
    Frank

  • Bean value storing to varable:

    I want to assign the bean value to a variable can it be done:
    <% int age = <bean:write property="age"/> ; %>

    I want to store that value returned by the bean:write into a local variable so that i can pass it to a script ..
    eg:
    <logic:iterate name="resourceRequirementForm" property="grades" id="grade" indexId="index">
    str varname='<bean:write name="grade" property="value"/>';
    </logic:iterate>
    can this be done: storing of value i a variable

Maybe you are looking for

  • Help with commandLink, actionListener, param in a simple CRUD example

    Hi All, I'm trying to build a very simple CRUD (create read update delete) interface as a proof of concept (concept being that I have some aptitude with JSF) and here is my problem: I have a dataTable, each row of which represents a campaign object.

  • Quarter period

    Hi All, I have a requirement to display the date fields on selection screen as follows: Taking into account todays date (10/01/2007), I need to display Starting date: 08/01/2007 & End date: 10/31/2007 Please help me coding. Thanks in advance. Satish

  • BAPI_CUSTOMER_CREATEFROMDATA1

    I'm trying to use BAPI_CUSTOMER_CREATEFROMDATA1 to update the customer master.  This does not work asking message the referencing customer number does not exist on the sales master. Since I want to create a new customer, I have nothing to reference d

  • SIU fails to create images

    Using SIU 10.6.7 on a machine updated to 10.6.8, trying to create a NetInstall image of a 10.6.3 Retail disc. SIU fails consistently, even after a reinstall of the server admin tools. This is what I get from the console log: 12/8/11 1:12:37 PM       

  • Finding your place in a nested sequence

    Plop an ordinary clip in the timeline, move the playhead to a spot in the clip, double-click the clip in the timeline, and the clip pops up in the source monitor with the playhead at the same spot in the clip. Place a nested sequence in a timeline, m