Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Problem sa servletom

[es] :: Java :: Problem sa servletom

[ Pregleda: 1983 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

normandija
Srbija

Član broj: 70439
Poruke: 364
*.teol.net.



+62 Profil

icon Problem sa servletom20.11.2007. u 17:05 - pre 200 meseci
da li neko zna sta bi mogao biti problem.....

na klik dugmeta u jsp strani treba da pozovem servlet i kad kliknem button on ga pozove (prikaze ga u adresbar liniji u browseru),ali se nista
ne desi....a trebalo bi da pozove proceduru i insertuje u bazu,a to ne uradi.
u web.xml je mapiran servlet

moze li ko pomoci....
Bolje izgubiti trenutak u zivotu,nego zivot u trenutku !!!
 
Odgovor na temu

nemnesic
nemnesic
Software Developer
Vranje Florida

Moderator
Član broj: 44355
Poruke: 802
*.com
Via: [es] mailing liste



+64 Profil

icon Re: Problem sa servletom20.11.2007. u 17:14 - pre 200 meseci
jel logujes nesto?
paste log da vidimo

nn
 
Odgovor na temu

anon315

Član broj: 315
Poruke: 1657
*.adsl-1.sezampro.yu.



+13 Profil

icon Re: Problem sa servletom20.11.2007. u 17:27 - pre 200 meseci
Nije mi jasno kako mislis da ti pomognemo ako nisi dao odgovarajuci deo jsp-a i doXXX metodu servleta?
 
Odgovor na temu

augustus
Novi Sad - Beograd

Član broj: 101581
Poruke: 358
89.216.110.*



+46 Profil

icon Re: Problem sa servletom20.11.2007. u 17:38 - pre 200 meseci
Code:

public class NekiServlet extends HttpServlet
{

    static Logger logger = Logger.getLogger(NekiServlet.class);
    
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try{
             //uradi nesto sa bazom ovde    
                         getServletContext().getRequestDispatcher("/jsp/neka_jsp_stranica.jsp").forward(request,response);

        } catch (Exception e) {
            logger.debug("SEVERE: desila se strasna greska..."+e.getMessage());
            e.printStackTrace();
            
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
        
    }
}


porbaj ovako da napises servlet, imaces neki trag u logu a na serverskoj konzoli ce ti se ispisati kompletan stack trace izuzetka.

"Čovek je biće koje se na sve navikava, i ja mislim da je ovo njegova najbolja definicija."
Fjodor M. Dostojevski
 
Odgovor na temu

normandija
Srbija

Član broj: 70439
Poruke: 364
*.teol.net.



+62 Profil

icon Re: Problem sa servletom20.11.2007. u 17:53 - pre 200 meseci
servlet.....

Code:
  package JavaBeans;

import java.io.IOException;
import java.io.PrintWriter;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;

import javax.servlet.*;
import javax.servlet.http.*;

public class FizickaLObrada extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=windows-1252";

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    public void DodajNovi(Connection conn,HttpServletRequest request, 
                      HttpServletResponse response) throws ServletException, IOException {response.setContentType                      (CONTENT_TYPE);{
        
                           
                
    CallableStatement cs = null;
                       
            try {
                    cs = conn.prepareCall("{call FIZICKA_LICA_AKCIJE.INS_FIZICKA_LICA(?,?,?,?,?,?,?,?)}");
            } catch (SQLException e) {
                  }
                            
            try {
                cs.setString(1, "23423");
                cs.setString(2, "432434");
                cs.setString(3, "dsfd");
                cs.setString(4, "Im");
                cs.setString(5, "Prez");
                cs.setString(6, "Adre");
                cs.setString(7, "Telef");
                cs.setString(8, "P");

                cs.executeQuery();
        //           cs.close();
        //           conn.close();
                                        
             } catch (SQLException e) {
             }
    }
                       }}



jsp strana....

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces/customizable" prefix="cust"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-template"
           prefix="template"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles"%>


<%@ page import="java.sql.*"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<jsp:useBean id="klasa" class="JavaBeans.LoginBean" scope="request" >
</jsp:useBean>

<jsp:useBean id="FizickaObrada" class="JavaBeans.FizickaLObrada" scope="request" >
</jsp:useBean>



<%      
     String FizickoLiceID = request.getParameter("FizickoLiceIDtxt");
     //String JMBG = request.getParameter("JMBGtxt"); 
     //String ImeLica = request.getParameter("ImeLicatxt");
     //String ImeOca = request.getParameter("ImeOcatxt");
     //String PrezimeLica = request.getParameter("PrezimeLicatxt");
     //String AdresaLica = request.getParameter("AdresaLicatxt");
     //String TelefonLica = request.getParameter("TelefonLicatxt");
     //String PolLica = request.getParameter("PolLicalistbox");
     session.setAttribute("Fizicko_Lice_IDSes",FizickoLiceID);
     
%>


<%
   Connection conn1 = klasa.konekcija((String)session.getAttribute("Korisnicko_ImeSes"), (String) session.getAttribute("LozinkaSes"));
   if ( conn1 == null)
   {
      %>
         <jsp:forward page="index.jsp"/>
      <%
   }
   
  
   
%>

<f:view>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    <title>FizickaL</title>
    
   </head>
   
   
  <body>
        <form name="LicaForm" action="JavaBeans.FizickaLObrada" method="post">   
 
  <img src="banner radomir jpg.jpg" height="120" width="726"/><table cellspacing="2"
                                                                           cellpadding="2"
                                                                           border="1"
                                                                           width="714"
                                                                           style="background-color:rgb(0,173,255);">
      <tr>
        <td width="130">
          <div align="center">
            <font color="#ffffff" face="Verdana">
              <strong>
                 &nbsp;&nbsp;Fizicka Lica</strong>
            </font>
          </div>
        </td>
        <td width="78">
          <div align="center">
            <font color="#ffffff" face="Verdana">
              <strong><a href="Dolasci.jsp">
                  Dolasci
                </a></strong>
            </font>
          </div>
        </td>
        <td width="96">
          <div align="center">
            <font color="#ffffff" face="Verdana">
              <strong><a href="Karton.jsp">
                  Kartoni
                </a></strong>
            </font>
          </div>
        </td>
        <td width="110">
          <div align="center">
            <font color="#ffffff" face="Verdana">
              <strong>Izvjestaji</strong>
            </font>
          </div>
        </td>
        <td width="108">
          <div align="center">
            <font color="#ffffff" face="Verdana">
              <strong><a href="Pretrage.jsp">
                  Pretrage
                </a></strong>
            </font>
          </div>
        </td>
        <td width="178">
          <div align="center">
            <font color="#ffffff" face="Verdana">
              <strong>Administracija</strong>
            </font>
          </div>
        </td>
      </tr>
    </table><p>
      &nbsp;
    </p><table cellspacing="3" cellpadding="2" border="1" width="714"
               style="background-color:rgb(212,208,200);">
      <tr>
        <td>
          <strong><em><font color="#ff0000" face="Verdana">
                Unos i promjena podataka o Fizickim licima&nbsp;
              </font></em></strong></td>
      </tr>
    </table><table cellspacing="2" cellpadding="1" border="0" width="714"
               style="background-color:rgb(216,228,248);">
      <tr>
        <td width="124">
          <font face="Tahoma" size="2">
            <font face="Tahoma">
              <font face="Tahoma">
                <strong>Fizicko&nbsp;lice ID:</strong>
              </font>
            </font>
          </font>
        </td>
        <td width="256">
          <input type="text" size="5"
                 name="FizickoLiceIDtxt" maxlength="7"/>
        </td>
        <td width="147">&nbsp;</td>
        <td width="133">
          <div align="center"/>
        </td>
      </tr>
      <tr>
        <td width="124">
          <font face="Tahoma" size="2">
            <font face="Tahoma">
              <font face="Tahoma">
                <strong>JMBG:</strong>
              </font>
            </font>
          </font>
        </td>
        <td width="256">
          <input type="text" size="12" maxlength="13" name="JMBGtxt"/>
          <font size="4">
            <font color="#ff0000">
              *
            </font>
          </font>
        </td>
        <td width="147">
          <div align="center"/>
        </td>
        <td width="133">
          <div align="center"/>
        </td>
      </tr>
      <tr>
        <td width="124">
          <font face="Tahoma" size="2">
            <font face="Tahoma">
              <font face="Tahoma">
                <strong>Ime:</strong>
              </font>
            </font>
          </font>
        </td>
        <td width="256">
          <input type="text" size="12" name="ImeLicatxt" maxlength="15"/>
          <font size="4">
            <font color="#ff0000">
              *
            </font>
          </font>
        </td>
        <td width="147">
          <div align="center">
            <input type="submit" value="Kreiraj Novi" name="operacija" style="font-weight:bold;"
                   />
            
          </div>
        </td>
        <td width="133">
          <div align="center">
            <input type="button" value="Snimi Izmjene"
                   style="font-weight:bold;"/>
          </div>
        </td>
      </tr>
      <tr>
        <td width="124">
          <font face="Tahoma" size="2">
            <font face="Tahoma">
              <font face="Tahoma">
                <strong>Ime oca:</strong>
              </font>
            </font>
          </font>
        </td>
        <td width="256">
          <input type="text" size="12" name="ImeOcatxt" maxlength="15"/>
          <font size="4">
            <font color="#ff0000">
              *
            </font>
          </font>
        </td>
        <td width="147">
          <div align="center">
            <input type="button" value="Obrisi Tekuci"
                   style="font-weight:bold;"/>
          </div>
          <div align="center"/>
          <div align="center"/>
        </td>
        <td width="133">
          <div align="center">
            <input type="button" value="Pretrazivanje"
                   style="font-weight:bold;"/>
          </div>
        </td>
      </tr>
      <tr>
        <td width="124">
          <font size="2">
            <strong><font face="Tahoma">
                Prezime:
              </font></strong>
          </font>
        </td>
        <td width="256">
          <input type="text" size="12" name="PrezimeLicatxt" maxlength="15"/>
          <font size="4">
            <font color="#ff0000">
              *
            </font>
          </font>
        </td>
        <td width="147">
          <div align="center">
            <input type="reset" value="Otkazi Unos" style="font-weight:bold;"/>
          </div>
          <div align="center"/>
        </td>
        <td width="133">
          <div align="center">
            <input type="button" value="Snimi / Izadji"
                   style="font-weight:bold;"/>
          </div>
        </td>
      </tr>
      <tr>
        <td width="124">
          <font size="2">
            <strong><font face="Tahoma">
                Adresa:
              </font></strong>
          </font>
        </td>
        <td width="256">
          <input type="text" name="AdresaLicatxt"/>
          <font size="4">
            <font color="#ff0000">
              *
            </font>
          </font>
        </td>
        <td width="147">
          <div align="center">
            &nbsp;<strong><font color="#ff0000">
                _________________
              </font></strong>
          </div>
        </td>
        <td width="133">
          <div align="center">
            &nbsp;
          </div></td>
      </tr>
      <tr>
        <td width="124">
          <font size="2">
            <strong><font face="Tahoma">
                Telefon:
              </font></strong>
          </font></td>
        <td width="256">
          <input type="text" name="TelefonLicatxt"/>
        </td>
        <td width="147">
          <div align="center">
            <h4>
              <strong><font face="Tahoma">
                  <a href="Doktori.jsp">
                    DOKTORI
                  </a>
                </font></strong>
            </h4>
          </div>
        </td>
        <td width="133">
          <div align="center">
            &nbsp;
          </div></td>
      </tr>
      <tr>
        <td width="124">
          <font size="2">
            <strong><font face="Tahoma">
                Pol:
              </font></strong>
          </font></td>
        <td width="256">
          <select size="1" name="PolLicalistbox">
            <option value="">
                Odaberi
              </option>
            <option value="">
                Musko
              </option>
            <option value="">
                Zensko
              </option>
          </select>
        </td>
        <td width="147">
          <div align="center">
            <h4>
              <font face="Tahoma">
                PACIJENTI
              </font>
            </h4>
          </div>
        </td>
        <td width="133">
          <div align="center">
            &nbsp;
          </div></td>
      </tr>
    </table><table cellspacing="3" cellpadding="2" border="1" width="714"
               style="background-color:rgb(212,208,200);">
      <tr>
        <td>
          <strong><em><font color="#ff0000">
                <strong><em><font color="#ff0000" face="Verdana" size="2">
                      <strong><em><font color="#ff0000" face="Verdana" size="2">
                            Polja sa crvenom zvjezdicom su obavezna.
                          </font></em></strong>
                    </font></em></strong>
              </font></em></strong>
        </td>
      </tr>
    </table></form></body>
</html></f:view>
<%-- 
  oracle-jdev-comment:preferred-managed-bean-name:ObradaFizicka
--%>



pokusao sam da unesem preko procedure konkretne vrijednosti,ali nece ni to
Bolje izgubiti trenutak u zivotu,nego zivot u trenutku !!!
 
Odgovor na temu

anon315

Član broj: 315
Poruke: 1657
*.adsl-1.sezampro.yu.



+13 Profil

icon Re: Problem sa servletom20.11.2007. u 17:55 - pre 200 meseci
Izvini, a gde ti je doGet ili doPost metoda?
 
Odgovor na temu

normandija
Srbija

Član broj: 70439
Poruke: 364
*.teol.net.



+62 Profil

icon Re: Problem sa servletom20.11.2007. u 18:00 - pre 200 meseci
cek,jel u okviru doGet treba da bude ova metoda DodajNovi().....znaci ovo sa uradio cisto da probam jel radi unos u bazu..
zato nisam koristio request.getParameter

ako mi mozes to malo pojasniti jer se ucim jos uvijek

ako ti je lakse ajd na PP

[Ovu poruku je menjao normandija dana 20.11.2007. u 19:14 GMT+1]
Bolje izgubiti trenutak u zivotu,nego zivot u trenutku !!!
 
Odgovor na temu

anon315

Član broj: 315
Poruke: 1657
*.adsl-1.sezampro.yu.



+13 Profil

icon Re: Problem sa servletom20.11.2007. u 18:22 - pre 200 meseci
Vidi, nisam se puno udubljivao u JSP stranu, ali evo ti par hintova:

Koristi MVC arhitekturu. Poenta je da izbegnes programiranje u JSP stranici i da servleti rade svoj posao, a jsp svoj.

Sto se tice servleta, on mora da ima doPost metodu (s obzirom da je to specificirano kao method u jsp stranici) koja treba da obradi zahtev. Tu mozes da pozoves neku svoju f-ju koja upisuje u db ili sta god vec da radi.

U principu, najbolje je da definises servlet koji uhvati zahtev, procita request parametre, eventualno napuni neki form bean (pogledaj apache commons beanutils, posto na zalost iz servleta ne postoji nacin da u cugu upumpas parametre u bean, dok u jsp to moze), odradis biznis logiku i napunis value objekat (neki bean), smestis ga u neki scope, a onda pomocu dispatcher-a, prosledis nekoj jsp strani da prikaze sta treba.

 
Odgovor na temu

[es] :: Java :: Problem sa servletom

[ Pregleda: 1983 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.