News script in JSP HELLP!!!

I am a beginer with JSP (i did something in PHP), i must do a news script for school and i don't have time to learn all about jsp. So cam someone tell mi the basics. I have the java and the tomcat server. I make a database in MYSQL but i dont know how to make it work with jsp.
I must do something very simple a login and a form for the input of the newses.
PS soooy for my english.

See whetehr ethis helps. Yuo need to change the Driver Class for MySQL
<HTML>
<BODY>
<%@ page import="java.sql.*" %>
<%
String strErrorMessage = " ";
Connection conn = null;
Statement stmt = null;
if (request.getParameter ("n_entrada") != null)
try
Class.forName("com.jnetdirect.jsql.JSQLDriver").newInstance();
conn = DriverManager.getConnection ("jdbc:JSQLConnect://<ServerIP>:Port/database=<dbname>/user=sa/password=sesame");
stmt = conn.createStatement ();
StringBuffer sbfQuery= new StringBuffer ();
sbfQuery.append ("INSERT INTO destinatarios ");
sbfQuery.append (" VALUES (" + request.getParameter ("n_entrada") + ",");
sbfQuery.append ("'" + request.getParameter ("cod_entrada") + "')");
stmt.executeUpdate (sbfQuery.toString ());
strErrorMessage = "Cod. Dest. Successfull inserted";
catch (Exception expGeneral)
expGeneral.printStackTrace ();
strErrorMessage = "" + expGeneral;
finally
if (stmt != null)
stmt.close ();
if (conn != null)
conn.close ();
%>
<form method="get" action="Request.jsp">
<table border="0" cellpadding="3" cellspacing="3" align="center">
<tr>
<td class="bolddark">N� Entrada :</td>
<td><input type="text" name="n_entrada" class="formstyleShort" value=""</td>
<td class="bolddark">C�digo Entrada:</td>
<td><input type="text" name="cod_entrada" class="formstyleShort" value=""></td>
</tr>
<tr>
<td colspan="4" align="left">
<input type="submit" value="Inserir" class="formButton">
<%-- Start of MR mr_smcoa_005 --%>
</td>
</tr>
<tr>
<td colspan="4" align="left">
<FONT COLOR='RED'><B><%=strErrorMessage%></B></FONT>
</td>
</tr>
</table>
</BODY>
</HTML>

Similar Messages

  • Help a new guys with JSP!

    Hi,
    i'm a new programer with JSP.
    I've created a class files that connect a database.
    But i would like to know how to write text with JSP?
    I would like to write a 'thank you' message after saving a form in a database.
    does its possible to have it in my class files?
    thanks for your help.

    Im not an expert on jsp or java but i will try to give my ideas.. i hope i can help you =)
    /* you could actually forward your servlet to your confirmation file like this : */
              ServletContext sc = getServletContext();
    .// just fill up here the variable msg , u cud write to its value your thank you message or something else like error messages
              RequestDispatcher rd = sc.getRequestDispatcher("/Confirmation.jsp?msg="+msg);          
              rd.forward(req, res);     
    /******* or u cud also throw ur request to the same jsp and display the ***/
    /******* message thru a form tag using javascript like this : ***/
    suppose your main jsp is this:
    <html>
    <head>
    <STYLE TYPE="text/css">
         .noBorder{
              border: white 0px solid;
              background-color: white;
              font-family:Arial;
              font-size:13px;
              font-weight: bold;
              color:green;
              width:300px;
              text-align:center;
    </STYLE>
    </head>
    <%!
    Connection conn;
    PreparedStatement pstmt;
    private doInsert(String name){
    // this is an oracle connection
    String sql = "INSERT INTO TABLENAME(FIELD1) VALUES(?)"
    try{     
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // just fill up the dburl , dnusername and dbpassword
    conn = DriverManager.getConnection(dburl,dbusername,dbpassword);
    pstmt = conn.prepareStatement(sql);
    pstmt.clearParameters(); // clear any previous parameter values
    pstmt.setString(1,name);
    pstmt.close();
    }catch(SQLException se){     
    }catch(Exception e){          
    }finally{
    if(conn!=null){
         try{
         conn.close();
         }catch(SQLException se){}
    %>
    <body>
    <form method=post"" name="msgscr">
    <tr><td colspan="2"><input type="text" name="msg" value="" class="noBorder" disabled/></td></tr>
    </form>
    <%
    if(request.getParamater("submit")!=null){
    // you could also add a return value for doInsert method to check whether the dbase insertion
    // is successful or not if the return value is true then the value for the document.msgscr.msg.value
    // is thank you otherwise u cud put "Unable to process your request" or other message
    doInsert(request.getParameter("name"));
    out.println("<script>document.msgscr.msg.value='Thanks you!!!!';</script>")
    %>
    <!-- this means that the request qill be thrown on this file-->
    <form method="post">
    <tr>
    <td>NAme : </td>
    <td><input type="text" name="name" value=""/></td>
    </tr>
    <tr><td colspan="2" align="center"><input type="submit" name="submit " value="Submit"></td></tr>
    </form>
    </body>
    </html>     
    /**** or you could also do the confirmation message just by adding an **/
    /**** alert message using javascript like this: **/
    <head>
    <script language="javascript">
    function ValidateCreate(theform){
         if(theform.name.value==""){
         alert("name is required");
         return false;
         }else{
         alert("Thank you!!!!");
    return true;
    </script>
    </head>
    <body>
    <form method="post" onsubmit="return ValidateCreate(this)">
    <tr>
    <td>NAme : </td>
    <td><input type="text" name="name" value=""/></td>
    </tr>
    <tr><td colspan="2" align="center"><input type="submit" name="submit " value="Submit"></td></tr>
    </form>

  • Is there any possibility running a Perl Script in JSP?

    Is there any possibility running a Perl script in JSP and get the value of the JSP variable? The JSP page is running in TOMCAT 5.0 server.

    i am created one script .... i want to replace it the older one ... it is possible in development server ..... is there any possibility to assingn the form in quality server ?????
    is there any other way to assign the form to transaction with out using NACE?.
    Well regarding you question about the system to have it assigned, ideally you need to assign it in development and mopve it up stacks. However, i aint sure of the roles you are assigned with for doing any config changes in QS. and the config needs to be done through NACE. Following is the process.
    You need to first find the Output type and the standard form attached to the existing program/ tcode. This info can be fetcehd from TNAPR table. Once you have got the details, you can then get into NACE tcode to configure your new custom form instaed of the existing Standard one. Get the application type, output type from TNAPR table. Then select the particular outpput type in NACE nad click on processing routine. This is the place where the new form name needs to be updated.
    Hope this helps!
    Cheers!
    Varna
    Edited by: Varna17 on Sep 24, 2009 7:10 AM

  • How to print new line in jsp page

    hi
    how to print new line in jsp page
    thanks

    \n - new line character is in java specific not HTML
    specific.Well, if the correct line separator sequence (by far not always \n) would be used, it does add a new line to the HTML output. Too bad that you don't want to see HTML but formatted text. The BR tag is a formatting element for the displayed text, not a line break in HTML. ;)

  • I want to know how to create a new script that can be run in batch proces in Photoshop Element 11 ?

    I want to know how to create a new script that can be run in batch proces in Photoshop Element 11 ?

    Have a look at the menu file/process multiple files. You can choose to add your signature (or the caption) to the image and export the new files.
    If that solution is not flexible enough, consider using the very affordable (12$)  Elements+ add-on which offers a 'meta stamp' script :
    http://elementsplus.net/v5/en/meta-stamp.htm
    Otherwise, have a look at other free and good solutions like Faststone Photoresizer, Xnview...

  • Java script with jsp

    hello friends,.
    please help me !! May i know how to retrieve values from list box in java script to jsp and store them in database..i am doing a project Employee Management system....
    please give me ideas .....

    thank you very much sir.......
    i have a combo box in java script having employee skills, if the employee select his skills and click on submit, the values should be stored in the database of the particular employee through JSP..
    the code that i have did is...
    <%
    String s1=(String)session.getAttribute("eid");
    String s2[]=request.getParameterValues ("menu2");
    int i=0;
    %>
    <%
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:empl2");
    PreparedStatement prep=con.prepareStatement("update skill(menu2) values(?) where eid=?");
    // prep.setString(1,s2);
    prep.setString(2,s1);
    i=prep.executeUpdate();
    con.close();
    catch(Exception e)
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body >
    <center><h4><u> Employee Assessment Application</u></h4></center>
    <%
    if(i>0)
    %>
    Your skills had been updated !!!!!
    <%
    else
    %>
    not updated
    <%
    %>
    <br>Best of Luck
    <h4><u>Back</h4>
    </body>
    </html>
    But the values are not getting stored....what to do
    thanx in advance

  • How to call script in jsp

    How to call script in jsp
    3A-_@. Feb 8, 2007 3:08 AM
    Hi,
    I have abc.jsp file where i want to call javascript on pressing submit button.
    <input type="text" name="UserName" value="" width="30" />
    <input type="submit" value="Submit" onclick=" <what should i write here??">
    here how to call script?
    and in the same abc.jsp file i have javascript ( i am not sure about the way i m accessing text value inside javascript is right or not)
    <SCRIPT LANGUAGE="javascript" >
    here how can i access UserName field value here??
    if(isThisNotNull(UserName))
    alert("UserName Is Mandatory");
    </SCRIPT>

    If you do it like Greeks says then the javascript variable will be set when the page loads (userName probably blank). You will want the current value from the input field so use getElementById().
    Edited by: gmachamer on Nov 21, 2007 7:23 AM
    oops, just noticed Greeks posted both replies... so what I should have said is use his first suggestion as the second is not what you want.

  • Query engine failed error for crytal report refreshing to new params in jsp

    Using licensed weblogic 8.1 server in production mode. Weblogic workhsop has inetegrated supprot for crystal reports 9. Using standalone report & accessing sql server through odbc, i got result for different parameters passed.
              Problem Area : Passing parameter to have specific report causes unexpected query engine failed error in com.crystaldecisions.report.web.viewer.CrystalViewer class. If viewer.refresh method is commented, then static (already saved) report is displayed through jsp. But using viewer.refresh method for dynamic report genertaion for new parameters through jsp gives above error.

    Hello
              I'm experiencing the same problem. Please let me know if you've any solution.

  • New Script for PE Tags-- iPhoto keywords

    I haven't tried it yet, but there's a new script for getting your Windows PE tags into iPhoto as keywords. Use the Write Tags to File command in PE first.
    http://scriptbuilders.net/files/iphotoiptckeywordimportexportutilities1.0.html

    Oh, whoops, I just posted this in the Technical forum before I came here. Never sure which one to use.
    This looks like the script a lot of folks were looking for.

  • New To java/JSP

    I am new to JAVA/JSP. I downloaded and installed tomcat. When I try to start it I am getting an error. (java.exe has encountered a problem and needs to close.) It will not start. I am running on Windows-xp. Anyone has any ideas as to what the problem could be ? Do I need to do anything special for Windows-xp ?
    Thanks for your help.
    - Madan

    Your description is not very detailed but I'm using Tomcat quite well to run my JSP/Beans stuff which I'm progressing in learning.
    Tomcat is actually "jakarta-tomcat-4.1.18", and to start the server I use d:\jakarta-tomcat-4.1.18\bin\startup.bat
    You need to set up various classpath and directory info in setclasspath.bat
    Assuming you then get the thing started, to test it out, go to
    http://localhost:8080/index.jsp (unless you changed 'localhost')
    Please post more questions if you want - I'm sure someone can help.
    Gary

  • Perl, my old scripts run but a I can't run new scripts

    I'm getting back into Perl and I have old practices files which will run fine. But when I write a new script nothing happens. Currently using 10.4.5, BBEdit 6.1 Lite. All my scripts have the following first line: #!/usr/bin/perl
    Old scripts work, if I type a new one and run it nothing happens except I get a new command line prompt.
    On the other hand if I remove the #!/usr/bin/perl line and go to the command line and type: perl programname. Programname will run!?!!?
    I still have to dig into the man pages on perlrun. Does anyone have a clue?
    Thanks, Dennis

    thanks for all the information. I really appreciate the replies.
    all of my experience is based on the O'Reilly book I mentioned above. I've tried to respond to all the comments but the order is not exact.
    chmod 755 uses an octal argument to change the permissions on the file.
    In particular the file becomes executable.
    1. which perl returned /usr/bin/perl which explains why the old perl programs run. Perl is where it's supposed to be.
    2. I haven't done anything to my system as far as a rehash goes(what is that anyway?)
    3. the wc -l command returned 0 hw2, meaning zero lines, bingo!! this must be it, don't you think?
    4. So why will BBEdit let me write, save, reopen files with content and UNIX sees the file as empty.
    5. when these programs are run, nothing happens I just get a new prompt.
    BTW the program, called hw2, in question reads:
    #!/usr/bin/perl
    print "hello, world. \n";
    get this: when I do cat hw2 I get a listing without the #!/usr/bin/perl at the top ie I see one line instead of two even though wc -l reports zero lines, what's up with that???
    I think that's everything for now. I'm going to look for another texteditor
    ps does it matter what the line end character is? I can choose Mac or UNIX.

  • New script dialog box only displays momentarily

    FM10 in TCS3 on Windows XP
    My coworker and I decided to investigate Extendscript and when we select File>Scripting>New from the main toolbar, the New Script dialog box flashes momentarily and then disappears. However, selecting Run displays the Choose Script dialog box, and selecting Catalog displays the Script Library.
    We have the latest patches and have installed DITA-FMx, FrameSLT, and SDLAuthorAssistant in FM.  Could any of those be affecting the scripting function?
    Thanks in advance.
    m

    Using TechCommSuite 3.0 on Windows XP.
    I always like to close loops and this posting is no exception.
    After almost two weeks of diligent sleuthing by Adobe techs and our own security personnel, we determined that the problem of ExtendScript not launching was an in-house problem.
    We have a DLP application that interfaces with our desktops for security purposes.  We needed to identify the ExtendScript.exe that was running in order to allow it to function.  Our security guy performed some wizardry and voila!  I had my ExtendScript window.
    Mary

  • New Scripts for Bridge posted

    From John Nack's blog: http://blogs.adobe.com/jnack/
    New scripts extend Bridge CS4
    Ever wanted to convert just about any file to JPEG from Bridge, or to attach browsed files to email? Photographer/scripter/Bridge quality engineer David Franzen has your back, having posted a set of great scripts to the Adobe Exchange. He writes:
    http://www.adobe.com/cfusion/exchange/index.cfm?event=productHome&exc=20

    Please post the solution how did you solve and what was the exact issue so that if anyone faces the same problem in future they can easily find answer from your post.
    Regards,
    Lalit Mohan Gupta.

  • Java script in Jsp Dynpage

    Hi all,
    Can any one give me a sample code for using a java script in jsp dynpage which invokes on client click. I mean i want to call a java script function on client click.

    Hi,
    Check these:
    https://wiki.sdn.sap.com/wiki/display/Snippets/JSPDynPage-Howtohideanelementonclienteventingaswellaschangethetextofthebutton+dynamically
    Search for onClientClick in above link and you will find the corresponding javascript function that is called when user clicks the button.
    Regards,
    Praveen Gudapati

  • New scripts

    I've posted a couple of new scripts on ps-scripts.com:
    http://www.ps-scripts.com/bb/viewforum.php?f=17
    XWatermark is a script for apply watermarks (shapes or text) with lots of
    options. I'll be adding as a it's own package on the ps-scripts sourceforge site
    in a month or two.
    CameraRaw is for doing stuff with raw files via Bridge. The big one in here is
    the ability to apply presets to raw files. This will be a part of xtools v1.6
    which should be released sometime soon.
    -X
    for photoshop scripting solutions of all sorts
    contact: [email protected]

    What's your idea of adding scripts to WebToGo? Retrieving information about client syncs doesn't required adding scripts to WebToGo; just create scripts (batch files, java programs, whatever you want) to select the data from the Mobile Admin schema and its appropiate tables (c$synch_history, etc).

Maybe you are looking for