Reputation: 87
I'm programming with jsp and java. I need to pass a value between jsp and a method java but in the same program. I read documentation about this but I don't find a solution.Could I do this?.
My code is:
if (form1.txtFamiliasSel.value=="<%=literales.getObject(TiposLiterales.TODOS)%>") {
if (marca == "0") {
marca = "0";
}
if (marca == "1") {
marca = "D";
}
if (marca == "2") {
marca = "C";
}
<%Familias lFamiliasSQL = new Familias(conn);
int lCodFilial = 0;
if (request.getParameter("cmbFilial") != null)
lCodFilial = Integer.parseInt(request.getParameter("cmbFilial"));
ResultSet datosFam = lFamiliasSQL.doSelectLiteralesFamiliasFilial
(lCodFilial,marca);%>
}
Upvotes: 1
Views: 69
Reputation: 1097
Create an Object of java class which contain your mothod, in jsp file and call the method using that object.
eg java class:-
public class T4 {
public String getResult(String st){
return st;
}
}
eg jsp file:-
<%
// this is a very basic way to get java object, you can also create beans.
T4 t4=new T4();
out.print(t4.getResult);
%>
Upvotes: 0
Reputation: 122008
Jsp is also Java code. They are not different. They are same. You don't need scriplets in between. Just remove those scriptlets.
Upvotes: 1
Reputation: 23826
Consider this code without unwanted scriptlets :
if (form1.txtFamiliasSel.value==literales.getObject(TiposLiterales.TODOS)) {
if (marca == "0") {
marca = "0";
}
if (marca == "1") {
marca = "D";
}
if (marca == "2") {
marca = "C";
}
Familias lFamiliasSQL = new Familias(conn);
int lCodFilial = 0;
if (request.getParameter("cmbFilial") != null)
lCodFilial = Integer.parseInt(request.getParameter("cmbFilial"));
ResultSet datosFam = lFamiliasSQL.doSelectLiteralesFamiliasFilial
(lCodFilial,marca);
}
Upvotes: 0