ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Poitras Christian <Christian.Poit...@ircm.qc.ca>
Subject RE: Why in Application is worked, but in JSP don't worked?
Date Mon, 24 Aug 2009 14:00:47 GMT
Hi,

You can see JSP as being close to an HTML page. It is better if you never put any scripting
in a JSP (being <% %>).
Many frameworks exists to simplify the use of JSP in an MVC framework. Strust and Stripes
are only a few examples.
In Struts you would put you database calls in Action class, in Stripes it is an ActionBean.

In both cases, you may want to put your database calls into a service class. The service methods
would then be called by you Action/ActionBean class.

You are better of reading about MVC framework (Stripes site at http://www.stripesframework.org/display/stripes/Home
is nice) and programming Patterns.

Christian

-----Original Message-----
From: bhaa [mailto:bhaa@yandex.ru]
Sent: Monday, August 24, 2009 9:49 AM
To: user-java@ibatis.apache.org
Subject: Re: Why in Application is worked, but in JSP don't worked?


Well, I not the big expert in JSP.
Explain, please if can, where it to make that then in JSP to have access to classes of tables
DB.

Alexander


Larry Meadors wrote:
>
> Good heavens, why would you EVER put that in a jsp?
>
> If you have to, the error is "Unable to compile class for JSP: An
> error occurred at line: 1 in the generated java file The type
> com.ibatis.sqlmap.client.SqlMapClient cannot be resolved. It is
> indirectly referenced from required .class files"
>
> Looks like it can't find all the classes.
>
> My advice: If it hurts when you hit yourself in the head with a
> hammer, then don't do it. If you can't do something you shouldn't in a
> jsp, don't. ;-)
>
> Larry
>
>
> On Mon, Aug 24, 2009 at 6:44 AM, bhaa<bhaa@yandex.ru> wrote:
>>
>> Hi, All.
>>
>> Explain to me please why it works in Application:
>>
>> public static void main(String[] args) {  Reader reader = null;
>> SqlMapClient client = null;  try {
>>    reader =
>> Resources.getResourceAsReader("com/rns/guvd/xml/SqlMapConfig.xml");
>>    client = SqlMapClientBuilder.buildSqlMapClient(reader);
>>    reader.close();
>>  } catch (IOException e) {
>>    e.printStackTrace();
>>  }
>>  ...
>> }
>>
>> but does not work in JSP:
>>  ...
>> <%@ page
>> import="com.ibatis.common.resources.*,com.ibatis.sqlmap.client.*"
>> %>
>>  ...
>> <%
>>  SqlMapClient sqlMapClient = null;
>>  try {
>>    Reader reader =
>> Resources.getResourceAsReader("com/rns/guvd/xml/SqlMapConfig.xml");
>>    sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
>>    reader.close();
>>  } catch (IOException e) {
>>    e.printStackTrace();
>>  }
>>  ...
>> %>
>>
>> org.apache.jasper.JasperException: Unable to compile class for JSP:
>>
>>
>> An error occurred at line: 1 in the generated java file The type
>> com.ibatis.sqlmap.client.SqlMapClient cannot be resolved. It is
>> indirectly referenced from required .class files
>>
>> An error occurred at line: 28 in the jsp file: /test.jsp SqlMapClient
>> cannot be resolved to a type
>> 27: <%
>> 28:     SqlMapClient sqlMapClient = null;
>> 29:     try {
>> 30:             Reader reader =
>> Resources.getResourceAsReader("com/rns/guvd/xml/SqlMapConfig.xml");
>> 31:             sqlMapClient =
>> SqlMapClientBuilder.buildSqlMapClient(reader);
>>
>>
>> An error occurred at line: 30 in the jsp file: /test.jsp Resources
>> cannot be resolved
>> 27: <%
>> 28:     SqlMapClient sqlMapClient = null;
>> 29:     try {
>> 30:             Reader reader =
>> Resources.getResourceAsReader("com/rns/guvd/xml/SqlMapConfig.xml");
>> 31:             sqlMapClient =
>> SqlMapClientBuilder.buildSqlMapClient(reader);
>> 32:             reader.close();
>> 33:     } catch (IOException e) {
>>
>>
>> An error occurred at line: 31 in the jsp file: /test.jsp
>> SqlMapClientBuilder cannot be resolved
>> 28:     SqlMapClient sqlMapClient = null;
>> 29:     try {
>> 30:             Reader reader =
>> Resources.getResourceAsReader("com/rns/guvd/xml/SqlMapConfig.xml");
>> 31:             sqlMapClient =
>> SqlMapClientBuilder.buildSqlMapClient(reader);
>> 32:             reader.close();
>> 33:     } catch (IOException e) {
>> 34:             e.printStackTrace();
>>
>>
>> Stacktrace:
>>
>> org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErro
>> rHandler.java:93)
>>
>> org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher
>> .java:330)
>>
>>  org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
>>        org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
>>        org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
>>        org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
>>
>> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext
>> .java:564)
>>
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
>> .java:302)
>>
>>  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
>>        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>>        javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
>>
>> Explain please to me in what a problem.
>> Alexander
>> --
>> View this message in context:
>> http://www.nabble.com/Why-in-Application-is-worked%2C-but-in-JSP-don%
>> 27t-worked--tp25115452p25115452.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>
>

--
View this message in context: http://www.nabble.com/Why-in-Application-is-worked%2C-but-in-JSP-don%27t-worked--tp25115452p25116383.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message