Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 19th, 2005, 04:16 AM
harshika harshika is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 24 harshika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 33 sec
Reputation Power: 0
java and jsp..please help .

my application is a web based library and i'm new to this field.
i created html files and jsp files and java files corresponding to the system .i want to know how should i test it using tomcat.my database is mysql .

Reply With Quote
  #2  
Old July 19th, 2005, 08:56 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
I would install tomcat on my local machine and copy your files to tomcat's webapps directory.

You can download tomcat here.
Here's an article on installing tomcat on windows.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #3  
Old July 19th, 2005, 12:05 PM
harshika harshika is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 24 harshika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 33 sec
Reputation Power: 0
Smile

thanks a lot .the article helped me a lot.

for my application i have created html pages as interfaces , and jsp(actually a very few yet) and java beans.

i created my application folder libraryapp under webapps and created 3 subfolders called conf,WEBINF and src. and it doesnt show my page.
is that correct?

Reply With Quote
  #4  
Old July 20th, 2005, 12:37 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Under which folder are you placing the HTML and JSP files?

Reply With Quote
  #5  
Old July 20th, 2005, 01:17 PM
harshika harshika is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 24 harshika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 33 sec
Reputation Power: 0
under webapps i created 3 folders,WEB-INF,src and conf.
i placed html and jsp in src folder. and web.xml in WEB-INF.

Reply With Quote
  #6  
Old July 20th, 2005, 01:24 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
You might want to create a single folder for your project.

TOMCAT_HOME/webapps/library_project/

try sticking your files in there.

Reply With Quote
  #7  
Old July 20th, 2005, 01:38 PM
harshika harshika is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 24 harshika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 33 sec
Reputation Power: 0
what is that main.conf file in conf folder? .i use intellij idea asthe ide.
how to deploy and do the war file?

Reply With Quote
  #8  
Old July 24th, 2005, 01:14 AM
harshika harshika is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 24 harshika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 33 sec
Reputation Power: 0
html and java

my application is a web based library system.
and i have to implement search facility of books.
i want to know how to get the resultset of a search to a web page's table(html table)
i.e, when search is done through excecuteQuery method of stmt object, how to send the result set to a table to show the output.i mean how to get the resultset object looped in to a table.
thanks in advance

Reply With Quote
  #9  
Old July 24th, 2005, 05:25 AM
gertcuppens's Avatar
gertcuppens gertcuppens is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 118 gertcuppens User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 28 m
Reputation Power: 5
This is a part of my JSP where I show the details of every found film in a list.


Code:
<DIV id=scroll1 style="BORDER:2px; OVERFLOW: auto; position: absolute; width: 700px; height: 250px; visibility: visible; left: 157px; top: 317px;">
  
  <table width="600" border="0" align="center" id="lijst">
  
	<% 
	for (Iterator i = filmLijst.iterator(); i.hasNext(); )
 		{ 
		Film film = (Film) i.next(); 
		%>

  		<tr>
  		  <td width="80"><input name="detail" type="submit" id="detail" value="<%=film.getFilmnummer()%>"></td>
      	  <td width="274"><%=film.getTitel()%> </td>
	  	  <td width="113"><%=film.getJaaruitgave()%></td>
	  	  <td width="115"><%=film.getGenre()%></td>
		</tr>
      <% } %> 
  </table>
  
</DIV>


In the declaration of my JSP, I've put :
Code:
<%@ page import = "java.util.Iterator" %>
<%@ page import = "org.gertcuppens.cluif.Film" %>
<jsp:useBean id="filmLijst" class="java.util.ArrayList" scope="session"/>


You need iterator to go through the ArrayList called filmLijst. Each of these objects you find has to be cast to an object of the class Film.

Where did I make this filmLijst ?
that was in the filmDao (DAO stands for Data Access Object, a java class which contains the SQL instructions)

Code:
public ArrayList zoekFilmOpLetter(String _letter)
		throws Melding
	{
		ArrayList filmLijst = new ArrayList(); 
		Connection con = null; 
		PreparedStatement ps = null;
		ResultSet rs = null; 
		try {
			StringBuffer zoekString = new StringBuffer();
			zoekString.append("select * from film ");
			zoekString.append("where titel like '" + _letter + "%'"); 
			System.out.println("zoekstring heeft de waarde " + zoekString); 
			con = getDatabaseConnection();
			ps = con.prepareStatement(zoekString.toString());
			rs = ps.executeQuery();
			
			if (rs == null)
				{
				ps.close();
				con.close();
				System.out.println("geen film gevonden"); 
				}
			else	
			    {
				while (rs.next() )
						{
						Film film = new Film (rs, "lijst");
						System.out.println("gevonden film is " + film.getTitel()); 
						filmLijst.add(film);
					
						} /* while rs.next() */ 
				rs.close();
				ps.close();
				con.close(); 
				} /* else : rs != null */
		
			} catch (SQLException sqlEx)
				{
				Melding melding = new Melding(sqlEx); 
				throw melding; 
				}
			   catch (Melding melding)
			   {
			   	throw melding; 
			   }
			   
		return filmLijst;
	}


The DAO is created and then used in the servlet.

Code:
private String behandelAlfabet (HttpServletRequest _request)
{
	Logger gcoLogger = Logger.getLogger("gco.log");		
	String radioLetter = _request.getParameter("radioLetter"); 	
	System.out.println("gcoController -- radioLetter is " + radioLetter); 	
	gcoLogger.debug("gcoController -- radioLetter is " + radioLetter);    
	if (_request.getParameter("selecteren") != null)
	{
		System.out.println("button is selecteren"); 
		gcoLogger.debug("button is selecteren"); 
		return SELECTIE_PAGINA; 
	}
	else if (_request.getParameter("zoeken") != null)
	{

		System.out.println("button is zoeken"); 
		gcoLogger.debug("button is zoeken"); 
		HttpSession sessie = _request.getSession(true);
		// if (sessie == null) sessie = _request.getSession(true); 
		FilmDao filmDao = new FilmDao();
		ArrayList filmLijst = new ArrayList(); 
		try {
			filmLijst = filmDao.zoekFilmOpLetter(radioLetter); 
		    Melding melding = new Melding("selectie op films beginnend met " + radioLetter); 
		    _request.setAttribute("melding",melding);
			} catch (Melding melding)
				{
			    // Melding melding = new Melding(exc);
			    //HttpSession sessie = _request.getSession(false); 
				/* plaats de melding in request; als je melding
				 * in sessie plaatst, blijft de foutmelding terugkomen
				 * ook al is ze niet meer van toepassing  
				 */
			    _request.setAttribute("melding", melding); 
			    System.out.println("gcoController -- melding klaargezet in behandelLetter() "); 	
			    System.out.println("melding boodschap is " + melding.getBoodschap());
			    System.out.println("melding SQL is" + melding.getSQLMelding());
				}
			sessie.setAttribute("filmLijst", filmLijst);
			return FILMLIJST_PAGINA; 
		}	/* selecteren geklikt */ 
	else 
		{
		System.out.println("behandelalfabet : onvoorzien geval"); 
		gcoLogger.debug("behandelalfabet : onvoorzien geval "); 
		return ALFABET_PAGINA;  
		}
} /* behandelAlfabet () */


Mind the line

Code:
sessie.setAttribute("filmLijst", filmLijst);


With this I put the Arraylist called filmLijst inside the session. And with this, the JSP can retrieve the found values and show them. All you have to do, is provide the next line in the JSP.
Code:
<jsp:useBean id="filmLijst" class="java.util.ArrayList" scope="session"/>

Reply With Quote
  #10  
Old July 28th, 2005, 01:23 AM
harshika harshika is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 24 harshika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 33 sec
Reputation Power: 0
hi,
thank you so much. your note is really good i learnt a lot from it.

Reply With Quote
  #11  
Old August 2nd, 2005, 01:55 PM
harshika harshika is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 24 harshika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 33 sec
Reputation Power: 0
jsp/java and tomcat

hi,
how to integrate jsp pages and java files and html files created in to a web based application.
i mean making the war file.

Reply With Quote
  #12  
Old August 20th, 2005, 03:01 AM
gertcuppens's Avatar
gertcuppens gertcuppens is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 118 gertcuppens User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 28 m
Reputation Power: 5
making a war file

I have never made a war file myself; the server I deploy my web apps, does not support this.
But I managed to find the following information with google :

Quote:
A war file is simply a jar file with a specific directory structure. Looked at another way, a jar/war file is simply a zip file with a different extension. You can manipulate jars/wars with a program that handles zip files, like winzip. No need to use the cumbersome jar command line tool.

The directory structure of a war file is

Code:
/ <- root of your web app. Should be an index.html/index.jsp file
/WEB-INF <- case specific. Must be all caps
/WEB-INF/classes <- this is where you class files go
/WEB-INF/lib <- any jar files you have go in here
/WEB-INF/web.xml <- this is the required web deployment descriptor


These links might be useful :
configuring web apps
creating a war file

Reply With Quote
  #13  
Old September 7th, 2005, 02:09 AM
harshika harshika is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 24 harshika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 33 sec
Reputation Power: 0
hi,
when my application (web based library) is tested it doesnt write data to the database. i created database using mysql.
when data is entered through webpage it doesnt write to the db. why?

Reply With Quote
  #14  
Old September 8th, 2005, 03:45 PM
gertcuppens's Avatar
gertcuppens gertcuppens is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 118 gertcuppens User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 28 m
Reputation Power: 5
try-catch block

Whenever you're executing SQL statements, you should be prepared for errors with a try catch block. Did you write this block ? Are there any SQLerrors you catch ?
ANd give us a piece of your code where you think it goes wrong.

Reply With Quote
  #15  
Old September 24th, 2005, 02:17 PM
harshika harshika is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 24 harshika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 33 sec
Reputation Power: 0
cannot connect to mysql DB

the code goes here of the coonection test..

Code:
class conTest {
    public static ConnectionPool pooler = new ConnectionPool();
    public static Connection con = null;

    public void init() {
        try {
            if (pooler.getDriver() == null) {
                pooler.setDriver("org.gjt.mm.mysql.Driver");
                pooler.setURL   ("jdbc:mysql://localhost/mygreatDB");
                pooler.setUsername("root");
                pooler.setPassword("password");
                pooler.setSize(5);
                pooler.initializePool();
            }

            con = pooler.getConnection();
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }
public static void main(String ar[]) {
        conTest ct = new conTest();
..............

and with this i cant connect with the DB..
what is wrong here ..please point it..

Reply With Quote
  #16  
Old September 26th, 2005, 09:53 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
What is the error you are getting?

in the future, try wrapping your code fragments in [code][/code] tags when pasting to the forum.

Reply With Quote