Is this technique dead

I’m including some code examples, where I mainly use JSP tags inside of a jsp page for most presentation. I use java classes (beans) for getter/setters and do all database updates and inserts through a class. My question is JSP dead now or is it and will it be still alive.

EXAMPLE EDIT PAGE: I present the data and after the edit, I use ajax to communicate with the page/and bean to update:


<html> 
<head> 
<script type="text/javascript" src="include/lock.js"></script>
<link rel="stylesheet" href="include/style.css" type="text/plain">
</head> 
<body> 
<%@ page language="java" import="java.sql.*" %>
<%@ include file = "util.inc" %>
<jsp:useBean id="db" class="SQLBean.DbBean" />
<jsp:setProperty
name="db"
property="petid"
param="petid" />

<%
out.println("the pet id is" + db.getpetid());

String varmv = request.getParameter("mv");
String vart11 = request.getParameter("t11");
String submit = request.getParameter("submit"); 
if(submit != null)
    {
    %>
    <jsp:setProperty
    name="db"
    property="petname"
    param="petname" />

    <jsp:setProperty
    name="db"
    property="species"
    param="species" />
    
  <jsp:setProperty
    name="db"
    property="sex"
    param="sex" />  
    
  <jsp:setProperty
name="db"
property="ownerid"
param="ownerid" />  
    
  <jsp:setProperty
name="db"
property="petowner"
param="petowner" />      
    
    
  <jsp:setProperty
name="db"
property="ostreet"
param="ostreet" />  

<jsp:setProperty
name="db"
property="dogpic"
param="dogpic" />



    <%
    int ri;
    db.connect();
    String sql = "UPDATE pets SET petname=?, ownerid=?, petowner=?, species=?, sex=?, ostreet=?, dogpic=? WHERE petid=?"; 
    db.updatepet(sql);
    out.println("<a href=trypage3.jsp?mv=" + varmv + "&t11=" + vart11 + ">back</a>");
    out.println("<br>");
    // out.println("<a href="+session.getAttribute( "reqsess" )+">sessback</a>");
    db.close();
    }
    %>
    
<%
int vpetid;
vpetid = db.getpetid();

String tmppetid = "";
String tmppetname = ""; 
String tpic = ""; 
ResultSet SQLResult = null;
db.connect();
String sql;
sql = "SELECT petid, petname, species, sex, ownerid, petowner, ostreet, dogpic FROM pets where petid = ?";
SQLResult = db.editSQL(sql);
while(SQLResult.next())
{ 
tmppetid = SQLResult.getString("petid");
tmppetname = SQLResult.getString("petname"); 
String varpic;
String vspecies;
String vsex;
String vownerid;
String voname;
String vostreet;
if (SQLResult.getString(8) != null && SQLResult.getString(8).length() > 0)
    {
    varpic = SQLResult.getString(8);
    }
else
    {
    varpic = "";
    }
if (SQLResult.getString(3) != null && SQLResult.getString(3).length() > 0)
    {
    vspecies = SQLResult.getString(3);
    }
else
    {
    vspecies = "";
    }
    
if (SQLResult.getString(4) != null && SQLResult.getString(4).length() > 0)
    {
    vsex = SQLResult.getString(4);
    }
else
    {
    vsex = "";
    }
if (SQLResult.getString(5) != null && SQLResult.getString(5).length() > 0)
    {
    vownerid = SQLResult.getString(5);
    }
else
    {
    vownerid = "";
    // vownerid = convJS(SQLResult.getString(5));
    }
if (SQLResult.getString(6) != null && SQLResult.getString(6).length() > 0)
    {
    voname = SQLResult.getString(6);
    }
else
    {
    voname = "";
    }    

if (SQLResult.getString(7) != null && SQLResult.getString(7).length() > 0)
    {
    vostreet = SQLResult.getString(7);
    }
else
    {
    vostreet = "";
    }    
%>

<table border=0 cellspacing=5 cellpadding=2> 
<form name="petsedit" id="petsedit" action="tryedit2.jsp" method="POST"> 

<tr> 
<td>Pet name</td> 
<td><input type="Text" name="petname" id="petname" size="20" value="<%=SQLResult.getString(2) %>"></td> </tr> 

<tr> 
<td>Species</td> 
<td><input type="Text" name="species" id="species"  size="20" value="<%=vspecies %>"></td> </tr> 


<tr> 
<td>Sex</td> 
<td><input type="Text" name="sex" id="sex"  size="20" value="<%=vsex %>"></td> </tr> 

<tr>    
<td>pet pic</td> 

<td><input type="Text" name="dogpic" id="dogpic"  size="20" value="<%=varpic %>"></td>
</tr> 
 
<!-- <tr>
<td>&nbsp;</td>    
<td>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="Write Back" onclick="WriteBack()"/> </td>
</tr> -->

<tr> 
<td>Owner id</td> 
<td><input type="Text" name="ownerid" id="ownerid"  size="20" value="<%= vownerid %>">&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="Write Back" onclick="WriteBack()"/>
<a href="#" onclick="getowner('1','zoooz','0');" id="idlookup1">find</a></td>
</tr>
   
    
<tr> 
<td>owner name</td> 
<td><input type="Text" name="petowner" id="petowner"  size="20" value="<%=voname %>"></td> </tr> 
     
    
<tr> 
<td>ostreet</td> 
<td><input type="Text" name="ostreet" id="ostreet"  size="20" value="<%=vostreet %>"></td> </tr> 
 
    
<tr>    
<input type="hidden" name="petid" id="petid" value="<%= SQLResult.getInt("petid") %>"> 
<input type="hidden" name="mv" id="mv" value="<%= varmv %>">
<input type="hidden" name="t11" id="t11" value="<%= vart11 %>">
</form>
</table> 


<%
out.println(db.getspecies());

}
out.println("<br>");
    out.println("<a href="+session.getAttribute( "reqsess" )+">sessback</a>");
out.println("<a href=\\"#\\" onclick=\\"updatepet('"+tmppetid+"')\\"> [save] </a>");
    SQLResult.close();

db.close();
%>

<a href="petsearch.htm">Back to search page</a>
</center> 
</body> 
</html>


Here is part of my js file showing the ajax call:


function updatepet(petid)
{
	petname = document.getElementById('petname').value;
	species = document.getElementById('species').value;
	sex = document.getElementById('sex').value;
	ownerid = document.getElementById('ownerid').value;
	petowner = document.getElementById('petowner').value;
	ostreet = document.getElementById('ostreet').value;
	dogpic = document.getElementById('dogpic').value;
     mv = document.getElementById('mv').value;
     t11 = document.getElementById('t11').value;
     var submit = "submit";
     petid = document.getElementById('petid').value;
     url = "tryedit2.jsp";
     params = "petid=" + petid + "&petname=" + petname + "&species=" + species + "&sex=" + sex + "&ownerid=" + ownerid + "&petowner=" + petowner + "&ostreet=" + ostreet + "&dogpic="+dogpic + "&mv="+mv+ "&t11="+t11+ "&submit="+submit;
     
	var http = getXMLHTTP();	
   	http.open("POST", url, true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() {
		if (req.readyState == 4) {
			if (req.status == 200) {						
				var z000z = '';						
					} else {
						alert("There was a problem while using XMLHTTP:\
" + req.statusText);
					}
				}				
			}			

        http.send(params);
	displayPopupDiv2();
		  
			
		
}

The class isn’t shown, but it is a typical class with getter/setters, prepared statements for the queries, the db connection, etc.

The util file simply escapes strings.

Are these techniques still ok? I have seen examples of jsf, and so far i do not like jsf.

but the use of scriplets <% %> in JSP (i.e. Java code) had been frowned upon for a long time.

What is the difference in <% %> and the new expression language tags:
Example from sun site

<h4>
  <h:outputText value="#{bundle.ItemPrice}"/>
  <h:outputText value="#{selected.price}">
    <f:convertNumber type="currency"/>
  </h:outputText>
</h4>

#{bundle.ItemPrice} Isn’t this like a tag to enbed some code in an html page? I’m trying to re-write my page of code in the new el.
In other words have they just changed the tag styles?

For a simple example it will probably be more lines of code in JSF but for a larger application it won’t necessarily be the case. In terms of maintenance, like 6 months after you haven’t touched the code, a JSF application will be much easier to work with than an all JSP solution.

On the Oracle/Sun site, it now does. It has it’s own expression language.

As of JSF 1.2, the expression language is shared between JSP and JSF. Typically a JSF page is a JSP page with JSF tags, but it’s still a JSP. This won’t always be the case if you use Facelets, but that’s another discussion.

I could probably write an example application and it wouldn’t be as many lines of code as you think. Just many different files, but I don’t really feel like doing so at this point since many JSF examples exist already (maybe not exactly like yours but similar…).

On the Oracle/Sun site, it now does. It has it’s own expression language.
Still, I’d like a simple example of a name,address,phone form in jsf and how to update a database on submit. There has to be a way to write a simple form to add to a database without 10,237 lines of code. Why in the blank does jsf require thousands of lines of code to do a simple thing?
See this link scary—
http://blogs.sun.com/carolmcdonald/entry/jsf_2_0_jpa_glassfish

No specific example of your jsf form I am afraid but hopefully something equally useful:

Btw, that kind of response wont win you a queue of people looking to answer your questions Jim…

What kind of F______ answer is that. I asked in above question what A JSF, JAVASERVER FACES, form would look like! I am trying to learn the new expression language! i PLAN TO RE-WRITE SOME CODE, BUT DON’T KNOW WEATHER TO USE JSF OR JSP. It is apparent that rushiku can’t read and does not have a life to speak of. Case closed on rushiku. I simply want to start learning some stuff in the new javaee6 spec. I simply asked for an example of a small edit form to point me in the right direction.

Jesus, put your eyes back in their sockets.

You asked ‘bottom line’, I replied ‘bottom line’.

As far as JSF vs JSP goes, you don’t get a choice. JSF doesn’t exist outside of JSP, which you would know if you had spent the three seconds needed to type ‘JSF’ into google and follow the first hit.

ttfn

Bottom line: no.

However, using JSP as a one-stop-shopping-spot for all your application’s needs was never popular and it is now most definitely dead.

Sure, you could design and build an all-in-one car-lawnmower-TV-shower-knife-refrigerator-kittenkilling-wallet, but who the f— would want to debug that?

(A: No one, after six months, not even you)

Thanks for the reply. Ok then, like I said I have looked over the sun docs on JSF, and from what I’ve seen it would take 4 to 5 times the code to do an edit page as in the example edit page I gave.
Just taking three fields for an example, petid, petname, and species, what would a JSF page look like to edit/update a record? Do you need to see the class I use to answer?
Is JSF the only alternative to use now?
Bottom line is JSP dieing?

JSP is not dead, but the use of scriplets <% %> in JSP (i.e. Java code) had been frowned upon for a long time. Most people will use some kind of MVC framework these days. Some popular choices are Struts, JSF and Spring MVC. I’m a big fan of JSF, but it’s not necessarily the easiest to learn.