
the user can create an event. In the create page, we have three buttons. Save as draft, preview and save and post buttons. Once the user entered all the datas and if he clicks the Preview button, you have to create a dynamic jsp which should read the contents from the db based on the event id. But this jsp url should be a public url. Means anyone can access it directly. ( something like .. upcomingeventz.ca/eventId=abc ). So it will be sharable in the social media sites.

Check this:
1)application.jsp:
<%@ page import="java.sql.*" %>
<html>
<head>
<script language="javascript">
function getRecord(){
var id=document.form.id.value;
var f=document.form;
f.method="post";
f.action='get.jsp?id='+id;
f.submit();
}
</script>
</head>
<body>
<br><br>
<form method="post" name="form">
<table>
<tr><td>Id:</td><td><input type="text" name="id"></td></tr>
<tr><td>Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<td><input type="button" value="Preview" onclick="getRecord();" ></td><td><input type="button" value="Save"></td>
</tr>
</table>
</form>
</body>
</html>
2)get.jsp:
<%@page language="java"%>
<%@page import="java.sql.*"%>
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
String id=request.getParameter("id");
int no=Integer.parseInt(id);
int sumcount=0;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select * from employee where id='"+no+"'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
%>
<tr>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
<td><input type="text" name="address" value="<%=rs.getString("address")%>"></td>
<td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td>
<td><input type="text" name="email" value="<%=rs.getString("email")%>"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>

In my Preview Button page is Gwt java file.... Its look like this..
PushButton previewButton = new PushButton(new Image("images/preview.png"));
previewButton.addClickListener(new ClickListener() {
@Override
public void onClick(Widget arg0) {
// TODO Auto-generated method stub
String url = "http://127.0.0.1:8888/project/preview.jsp?gwt.codesvr=127.0.0.1:9997";
redirect(url);
}
});
How to add that javascript in this page?
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.