Ashik Ashok Ashik Ashok - 1 year ago 195
MySQL Question

how to create a Blog using jsp or xml?

i want to develop simple blog application using jspservlet in academic projects ,i don't how to start the project can anyone please give me scratch code of jspservlet to start my project,it will be very helpful for me to start my project

Answer Source

I suggest you to do a bit of research in google before asking this kind of questions in forums like stackoverflow.

If you want to create a basic blog in java, you must be aware of JSP,Servlets.

To get started, divide your project into various modules. I will try to walk you throught the steps you can follow to create a simple blog application.

You can divide your simple blog application into different parts.

1.Login Page

2.Home Page with a New Post Button.(where all your blog posts are displayed)

3.Add Post Page

You can google "how to create login page in jsp and servlet with database" and you will find tons of search results which will show you how to implement a login functionality.

Next you need to design the Add Post page, at very basic level you need to have 1 text field for the title of your blog post, 1 text area for the content of your blog post and one submit button to submit your content.

        <form method="post" action="create-post">
            <label>Title</label> <input name="title" type="text">

            <label for="content">Post</label>
            <textarea name = "content" id="content" rows="10"></textarea>
            <input type="submit" value="Submit" />


Once you POST this data, in the servlet you need to access the "title" and "content" parameters.

        String title = request.getParameter("title");
        String content = request.getParameter("content");


        String htmlContent = TextUtil.convertTextToHTML(content);

        Post post = new Post(title, htmlContent, newDate);

        request.getServletContext().setAttribute("post", post);

        RequestDispatcher rd = getServletContext().getRequestDispatcher(
        rd.forward(request, response);

You need to convert the "content" from Text to HTML to display as a blog post in your home page.

I have given some very high level overview of creating a very simple blog application. If you want to build any kind of application, try to search in Github. I am pretty sure that you will find some code. Study that code, try to understand and learn.

Here is one of my sample project to create a simple blog application using JSP Servlets.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download